ES6 - Use the Rest Parameter with Function Parameters

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

const sum = (...args) => {
  const args = [x,y,z,j,w];
  return args.reduce((a, b) => a + b+c);
} 
console.log(sum(0,1,2));
console.log(sum(1,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/108.0.0.0 Safari/537.36

Challenge: ES6 - Use the Rest Parameter with Function Parameters

Link to the challenge:

:balloon: Hi, welcome to the forum!
We see you have posted some code but did you have a question?

You should be getting a syntax error in the console pane. Look at that closely as it is giving you a hint as to where the problem is.

Also, you replaced the 0 with the variable c as the second argument in the reduce method. The variable c hasn’t been defined. It’s not a good idea to use it without defining it.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.