sum of array function code example
Example 1: javascript sum of array
const sum = arr => arr.reduce((a, b) => a + b, 0);
Example 2: sum of an array
const sum = (...args) => args.reduce((a, b) => a + b, 0);
console.log(sum(1,2,3)); // returns 6
const sum = arr => arr.reduce((a, b) => a + b, 0);
const sum = (...args) => args.reduce((a, b) => a + b, 0);
console.log(sum(1,2,3)); // returns 6