Javascript’s Reduce method

The Reduce method reduces an array into a single value by applying a callback function to each element in the array, starting with the leftmost to the rightmost element.

As a simple example, we could use reduce() to find the sum of all the numbers in an array.

const numbers = [3, 2, 5, 7, 8, 10];
const sum = numbers.reduce(function (total, item) {
  return total + item;
});
// Returns 35

In ES6 syntax,

const numbers = [3, 2, 5, 7, 8, 10];
const sum = numbers.reduce((total, item) => total + item);
// Returns 35

More great examples of the Reduce method:
https://medium.freecodecamp.org/reduce-f47a7da511a9

Full documentation:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce