var arr = [1, 2, 3, 4, 5];
var sum = arr.reduce((prev, curr) => prev + curr);
console.log(sum);
// Output: 15
You can also specify an initial value
var arr = [1, 2, 3, 4, 5];
var sum = arr.reduce(function (previousValue, currentValue, currentIndex, array) {
return previousValue + cur...