const sum = (...a) => {
const args = [...a];
return args.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3, 4)); // 6
cant pass the last test
const sum = (...a) => {
const args = [...a];
return args.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3, 4)); // 6
cant pass the last test
The
sumfunction should use the...rest parameter on theargsparameter.
instead your function has an a parameter.
well i did this but gave me an error
SyntaxError: unknown: Identifier ‘args’ has already been declared
thanks fixed it…