Need one result from an array? A loop can visit every item and update a running value, but `reduce` expresses that aggregation directly. It turns an array into a single value by repeatedly applying a callback. section 9.1.4
Listing 9.12. Aggregating items with reduce
const numbers = [1, 2, 3, 4];
const sum = numbers.reduce((aggregated, number) => #A
aggregated + number, 0); #A
assert(sum === 10, "The sum of first four numbers is 10");
The sum starts at `0`. For each number, the callback adds that number to the accumulated value; the final result is `10`. section 9.1.4
The callback receives the previous result—or the initial value on its first call—and the current item. The last callback result becomes the result of `reduce`. section 9.1.4








