reduce function example
playing around with reduce function in js
JavaScript
var testValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function reducer(valueArray) {
return valueArray.reduce(function(accumulator, currentValue, currentIndex, array) {
return accumulator + currentValue;
})
}
console.log(reducer(testValue));