Using the reduce array helper in ES6
July 23, 2017 Leave a comment
ES6 comes with a number of helper methods that can be applied to arrays. One of these is called reduce which can be used in aggregation scenarios where we in each loop need to use the result of the previous loop. Reduce is certainly a bit more difficult to grasp and use than the other array helpers introduced in ES6. If you’re familiar with C# and LINQ then the reduce array helper is similar to the Aggregate LINQ extension method.
Let’s see an example.