reduce()
ile dizideki tüm değerlerin toplamını bulmaklet sum = [0, 1, 2, 3].reduce(function (accumulator, currentValue) {
return accumulator + currentValue
}, 0)
console.log(sum) // 6
// alternatif olarak arrow function ile şöyle yazılabilir
let total = [ 0, 1, 2, 3 ].reduce(( accumulator, currentValue ) => accumulator + currentValue, 0)
console.log(total) // 6