Don't understand this part with: Use the Rest Parameter with Function Parameters

Tell us what’s happening:
When i check out the link:

it gives an example code of the rest parameter with n1, n2, n3
being replaced with …n
why doesn’t the same logic aplies to the lesson?
And can’t we use x, y z
to …z?

Things I tried to make any scense of it so far is:
As far as i understand it it replaces and stores the values
but is limited to only the ammouth of variables you have
a and b does not exceed this logic so thats not the problem

Your code so far

const sum = (...z) => {
return args.reduce((a, b) => a + b, 0);

Your browser information:

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

Challenge: Use the Rest Parameter with Function Parameters

Link to the challenge:

In your code snippet you have z as the array but its never used when performing the reduce

1 Like

the logic is the same, but the reduce method is used on the args variable which is now undefined

and one of the tests say:

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

the logic is the same, but it needs to be applied in the required way, which is using the right parameter name

1 Like