is there any difference between the reduce function and the spread of values operator in js code example
Example 1: the rest operator javascript
function sum(...numbers) {
return numbers.reduce((accumulator, current) => {
return accumulator += current;
});
};
sum(1,2) // 3
sum(1,2,3,4,5) // 15
Example 2: .reduce mdn
arr.reduce(callback( accumulator, currentValue[, index[, array]] )[, initialValue])