JavaScript's Reduce

One of the functions I had no previous experience with before Flatiron, was the reduce method.  While I had worked with find, filter, and map functions, reduce was foreign.  Not only that, reduce seemed counterintuitive.  The idea of the reduce method is to take a bunch of values and return a single value.  That makes sense right?  The syntax of the reduce method is more complicated.  It takes 4 arguments and has 6 parameters.  


The two non-argument parameters are:


The reducer's arguments:


The basic idea is to do this:  Array.Reduce(function(accumulator, current value, index, array) {

return accumulator + current value

}, initial value)

 where the callback is the function that determines how the accumulator and current value is used.  In the above example, the two are simply added, so a reduction of an array of the elements [1, 2, 3, 4] would result in 10, if no initial value was provided.