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

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