javascript use reduce to sum array code example
Example 1: javascript reduce sum
let nums = [1, 2, 3];
nums.reduce((curr, next) => curr + next);
Example 2: syntax of reduce in js
[1,2,3,4,5].reduce((acc, current)=>acc+current, 0)
let nums = [1, 2, 3];
nums.reduce((curr, next) => curr + next);
[1,2,3,4,5].reduce((acc, current)=>acc+current, 0)