const num = [1, 3, 1, 1] const reducer = (accumulator, currentValue) => accumulator + currentValue; const sum = num.reduce(reducer); console.log(sum) // (1+3+1+1) = 6