Tell us what’s happening:
I managed to pass the lesson by adding the rest operator to the provided code, but I then also tried to simplify the code.
I can’t pass the lesson with this code as FCC says that I am not using the rest operator with args…
I get no error in the console, and the code seems to work fine when testing. I am wondering if anyone can tell me what is wrong with this code.
Cheers!
Your code so far
const sum = (...args) => args.reduce((a,b) => a+b, 0)
console.log(sum(0));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters