ES6 - Use the Rest Parameter with Function Parameters

Tell us what’s happening:

Helllo Good day i have been staring at my screen for some time now unable to understand or come up with an answer for the last test ```
sum
should be an arrow function which uses the rest parameter syntax (
) on the args parameter.

Your code so far

const sum = (...arg) => {
  const args = [...arg];
  let total = 0;
  for (let i = 0; i < args.length; i++) {
    total += args[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/120.0.0.0 Safari/537.36

Challenge Information:

ES6 - Use the Rest Parameter with Function Parameters

hello and welcome to fcc forum :slight_smile:

  • on line 2, you dont have to use “[…arg]” like that instead you can simply use “arg”, because spread operators will contain an array of “args”
  • considering that you can simply use “…args” in function signature and remove “line2” entirely

happy coding :slight_smile:

it worked , Thank you so much