Нормальный способ
const letter = prompt(`What do you want?`).toLowerCase();
const array = ['bread','milk','apple', 'juice','banana','peach', 'pineapple','beer','Putin'];
const result = array.filter((item) => item.toLowerCase().includes(letter));
alert(result);
Способ с map
const letter = prompt(`What do you want?`).toLowerCase();
const array = ['bread','milk','apple', 'juice','banana','peach', 'pineapple','beer','Putin'];
const result = [];
array.map((item) => {
if (item.toLowerCase().includes(letter)) {
result.push(item);
}
});
alert(result);