Tell us what’s happening:
Ive solved the challenge fine, but cant understand what the use or purpose of the 0 is at the end of the arrow function. Is this a radix?
Ive tried reading up the .reduce method, IIFEs etc to find the answer, but cant find an answer.
Your code so far
const sum = (...args) => {
return args.reduce((a, b) => a + b, 0);
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0.
Challenge: Use the Rest Parameter with Function Parameters
They actually did add a video with that information
As from my basic understanding of it the rest paramter needs 3 arguments
1: a
2: b
3: 0
And thats why we have a 0 because a null value is often use as a placeholder .
I can be wrong ofcourse
As you can see it is explained here, it is an initial value. It is serving as telling the code which part of the array is picked first. You can read more here:
MDN is always the best place to look up these kind of stuff, because they have a fully detailed explanation about almost all WebDesign Stuff.