Problem help please

const sum = (...a) => {
  const args = [...a];
  return args.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3, 4)); // 6

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters

cant pass the last test

You are not using an args parameter. You have a parameter named a.

1 Like

The sum function should use the ... rest parameter on the args parameter.

instead your function has an a parameter.

1 Like

well i did this but gave me an error
SyntaxError: unknown: Identifier ‘args’ has already been declared

thanks fixed it…

1 Like

When you use args as a parameter, you should not be declaring it again in your code. I would need to see the code you tried.