Use the Rest Operator with Function Parameters1

Tell us what’s happening:

When isn’t right please tell me?

Your code so far


const sum =(...args) => {
return args.length > 0 ? args.reduce((num, i) => num+=i) : 0
}
console.log(sum(2,3,4)); 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters

Looks like you overcomplicated the solution.

Don’t use the rest operator at the beginning of the function , but use it when the 2nd function inside the wrapper function is returned. So modify below “use strict”. You may have to reset your code to do it easily.

Arrow functions do not have their own arguments object
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions.

Ah OK but i do it with @shimphillip It isn’t difficult but thank you

Yeah, but is good to know it is not your fault.

I think you have a colon not a comma right before your initial accumulator. The 0

Also look at your parentheses grouping

Yes but I passed the test I do it.Thank you for helping.

A post was split to a new topic: Stuck on Use the Rest Operator with Function Parameters challenge