Tell us what’s happening:
const sum = (…n) => {
const args = n;
let total = 0;
for (let i = 0; i < args.length; i++) {
total += args[i];
}
return total;
}
Your code so far
I’m getting the desired output, but I’m not sure why it’s not passing the last test.
const sum = (...n) => {
const args = n;
let total = 0;
for (let i = 0; i < args.length; i++) {
total += args[i];
}
return total;
}
console.log(sum(1,2,3))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Challenge Information:
ES6 - Use the Rest Parameter with Function Parameters