[Spoiler- Dont read on if you are still working on the problem]
@colinthornton Yes, I understand that - but if you look at the number of people who have asked questions a lot are getting caught up with the fact of a new function.
all we have to do is undeclare const args since its declared by the spread out ( method? ) …args - I took a minute to realize that reduce() is not needed… Im sure a lot of greenhorns see that and freak a bit, while Im sure a lot see it and dont flinch since they know what the quesiton is asking.
I guess it would have been easier if they just used something else for the return that we had worked on, as to not get ourselves worked up on something that was not needed.
I know it’s been a while since this was asked, but it’s worth pointing out (and it’s been my experience with previous lessons as well) that this is much easier than what it looks like.
Since it contains some concepts we haven’t seen previously (“reduce”), and the new rest parameter is only explained briefly (appreciate in a short lesson you can’t go too much into detail), it’s easy to get stuck.
I passed it by using:
const sum = (...args) => {
return args.reduce((a, b) => a + b, 0);
}
console.log(sum(1,2,3,4))
You basically change the function argument to use the rest parameter ("…name") and delete the second line as you don’t need it at all. You don’t need to touch the “reduce” part. Use console.log to test it out.
Lastly, it’s always good practice to develop the habit of also looking things up on our own and figure them out - it’s a lot of what we’re going to do as developers anyway.
Tossing my hat into the ring here. No explanation of the .reduce() method now has me looking up exactly what the .reduce() method does.
I understand we should be looking up things that we do not know, however, in order for a learner to logically understand what’s going on here, it seems like a mandatory pre-req to understand the .reduce() method.
The problem itself should alert the learner that this understanding is needed to follow the logic.
I am used to looking things up ALL THE TIME. Not such a great idea to introduce them in a lesson without even providing a reference link. I believe it was an oversight. I have more good things to say about FCCs JS course than the E6 course. It’s not as thorough as JS was.
If I need to look out for stuff over and over during a course that’s not good news. Another thing is to look up addtl stuff because I want to learn more about it. I agree with the majority. It is frustrating to run into these dead ends . My advice is to keep them to a min in the context of a course. If done so repeatedly it can end up undermining confidence and motivation.