ES6 - Use the Rest Parameter with Function Parameters

Hello, what could be wrong with my code because it’s failing this test
sum should be an arrow function which uses the rest parameter syntax (... ) on the args parameter.

Your code so far

const sum = (...k) => {
  let total = 0;
  for (let i = 0; i < k.length; i++) {
    total += k[i];
  }
  return total;
}

Your browser information:

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

Challenge Information:

ES6 - Use the Rest Parameter with Function Parameters

1 Like

Try to change the k to args.

1 Like

It worked perfectly.
Thank you.

1 Like

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