Reduce an array to a single value:
let numbers = [1, 2, 3, 4]
let sum = numbers.reduce((acc, n) => acc + n, 0)
console.log(sum) // 10
let product = numbers.reduce((acc, n) => acc * n, 1)
console.log(product) // 24
The callback receives an accumulator and current element. The second argument ( or above) is the initial accumulator value.