Functional JavaScript: How to Use Array Reduce for More Than Just Numbers

Functional JavaScript: How to Use Array Reduce for More Than Just Numbers

The accumulator can be something completely different from the array elements. For example, our accumulator might be a string, while our array contains numbers:

Now, this is just an example to make the point. But there’s no reason that single value can’t be an array.

Source: jrsinclair.com