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