1const sum = (...input) => {
2 input.reduce((a, b) => a + b)
3}
4
5// Example
6sum(1, 2, 3, 4)
7//output
810
1x = sumAll(1, 123, 500, 115, 44, 88);
2
3function sumAll() {
4 let sum = 0;
5 for (let i = 0; i < arguments.length; i++) {
6 sum += arguments[i];
7 }
8 return sum;
9}
1const sum = (...args) => args.reduce((a, b) => a + b);
2
3// Example
4sum(1, 2, 3, 4); //10