I need to know about this Q&A

Tell us what’s happening:

Your code so far

const sum = (x, y, z) => {
const args = [x, y, z];
return args.reduce((a, b) => a + b, 0);
console.log(sum(1, 2, 3)); // 6

Your browser information:

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

Challenge: Use the Rest Parameter with Function Parameters

Link to the challenge:

1 Like

well if you want to know more about it try the bellow link

also the example gives out a function

function howMany(...args) {

don’t u think using a function instead of

const sum = (x, y, z) => {

can help you out here?

I hate when FreecodeCamp introduces new functions without even explaining them… directly from the problem in questions

The rest parameter eliminates the need to check the args array and allows us to apply map() , filter() and reduce() on the parameters array.

Yet map(),filter() and reduce() have not been taught… how is someone expected to use these, if these are not even used in the example?


You don’t have to make any changes to this line in the starter code:

return args.reduce((a, b) => a + b, 0);

Knowledge of how to use reduce to sum up an array of numbers is not needed to solve the problem.


[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.


Yes. It should be introduced clearly before.


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);



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.


@jagcb @chrismdbb @thang.phamccie

I too was frustrated with not knowing what the .reduce method was doing…
I found this article helpful in understanding that


I quit trying to be practical. Here is my caveman solution:

const sum = (…args) => {
var summ = 0
for(let i = 0; i < args.length; i++){
summ = summ + args[i];
return summ ;

1 Like

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.

  • Edit - I still don’t understand this problem.

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.