ES6 - Use the Rest Parameter with Function Parameters

Tell us what’s happening:
everything works fine but the last test in this question is not understandable, the answer is correct but the last test doesnt passes

Your code so far

const sum = (...x) => {
  let args = x;
  let total = 0;
  for (let i = 0; i < args.length; i++) {
    total += args[i];
  }
  return total;
}
console.log(sum(2,3,4));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67

Challenge: ES6 - Use the Rest Parameter with Function Parameters

Link to the challenge:

  • sum should be an arrow function which uses the rest parameter syntax (...) on the args parameter.

It is telling you that the parameter should be named args, not x.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.