How to use the Reduce formula?
In the meantime this post has some practical examples https://thecodebarbarian.com/javascript-reduce-in-5-examples.html This is the key benefit “The reduce ( ) method works in a similar manner to the forEach ( ) method , with the added ability to collect the result of each iteration as a single value . ” Here 's a quick reduce usage example to show using the formula to sum up the total property of a list of objects in an array : 1 . the formula in the reduce is summing the item total , and the result , which is the result of the accumulator each time the reducer loops 2 . The accumulator starts at 0 , as we start with 0 items until we go around in a loop to sum all the items up https://editor.nordcraft.com/projects/reduce_example/branches/start/components/HomePage?canvas-width=800&canvas-height=800&selection=formulas.ojBjiX&rightpanel=style I 'm one of those devs that love the reduce function as it 's quite powerful and I use it quite a lot . It takes an array of type T and turns it into any type Y . (T [ ] ) = > Y . It 's quite useful if you want to turn an array into an object for example . That 's what I use it for mostly . One could argue that map +fromEntries could do the same . It 's a matter of preference . All the other array functions like map and filter and join etc . can be written using reduce . A side note : in some programming languages reduce is called fold or foldLeft . Reduce can also reduce (heh ) the number of iterations of an array . If you want to change the type of the array and the size of it without reduce you would need to loop it twice . Once with map and once with filter . Reduce allows you to get the same result in just one iteration . It can be useful for large datasets .