const fruits = ['🍌', '🍓', '🍇', '🍓'];
fruits.forEach(function (value) {
console.log(value);
});
fruits.forEach((value) => console.log(value));
const item1 = { name: '🥛', price: 2 };
const item2 = { name: '🍪', price: 3 };
const item3 = { name: '🍙', price: 1 };
const products = [item1, item2, item3, item2];
let result = products.find((item) => item.name === '🍪');
console.log(result);
result = products.findIndex((item) => item.name === '🍪');
console.log(result);
result = products.some((item) => item.name === '🍪');
console.log(result);
result = products.every((item) => item.name === '🍪');
console.log(result);
result = products.filter((item) => item.name === '🍪');
console.log(result);
console.clear();
const nums = [1, 2, 3, 4, 5];
result = nums.map((item) => item * 2);
console.log(result);
result = nums.map((item) => {
if (item % 2 === 0) {
return item * 2;
} else {
return item;
}
});
console.log(result);
result = nums.map((item) => [1, 2]);
console.log(result);
result = nums.flatMap((item) => [1, 2]);
console.log(result);
result = ['dream', 'coding'].flatMap((text) => text.split(''));
console.log(result);
const texts = ['hi', 'abc'];
texts.sort();
console.log(texts);
const numbers = [0, 5, 4, 2, 1, 10];
numbers.sort();
console.log(numbers);
numbers.sort((a, b) => a - b);
console.log(numbers);
result = [1, 2, 3, 4, 5].reduce((sum, value) => (sum += value), 0);
console.log(result);