map, filter, find and reduce

The four array methods you will use every day. None of them changes the original array.

JavaScript · map, filter, find and reduceBeginner
const prices = [10, 25, 5, 40];

const doubled = prices.map(p => p * 2);              // [20, 50, 10, 80]
const big     = prices.filter(p => p > 9);           // [10, 25, 40]
const first   = prices.find(p => p > 20);            // 25
const total   = prices.reduce((sum, p) => sum + p, 0); // 80

console.log(prices.includes(5), prices.some(p => p > 30), prices.every(p => p > 1));
arraymapfilterreduce