processes each member of the array and returns a single output value
callback | function | a function that will be executed on each element in the array |
initialValue | any | the value to be used as the first param to the first call of the callback |
// processes each item in data collection and returns the total size
var totalSize = vault.data.reduce(function(total, item){
return total + item.size;
},0);
The callback function may have up to three parameters: