Pipe data through array methods: 15 levels chaining map, filter and reduce. The densest JavaScript functional programming game for arrays.
.map() makes a new array by applying a function to each element. The original array doesn't change.
.filter() makes a new array containing only the elements that pass the condition (the callback returns true).
.reduce() accumulates all the array elements into a single value. It takes a callback(accumulator, currentValue) and an initial value.
.sort() sorts an array. Without a comparator, sort orders them as strings (10 before 2). For numbers, always use the comparator (a, b) => a - b.
.find() returns the first element that passes the condition. Different from .filter(), which returns all the matching elements in an array.
.slice(start, end) takes a piece of the array without changing the original. A negative index counts from the end. .reverse() flips the array's order.
And more, 15 levels in all.