map filter reduce javascript mdn code example
Example 1: reduce javascript
let sum = arr.reduce((curr, index) => curr + index);
Example 2: js map filter reduce
const numbers = [1, 2, 3, 4];
const doubled = numbers.map(item => item * 2);
console.log(doubled); // [2, 4, 6, 8]
Example 3: js map filter reduce
const numbers = [1, 2, 3, 4];
const evens = numbers.filter(item => item % 2 === 0);
console.log(evens); // [2, 4]