Use the Rest Operator with Function Parameters, correct answer is not accepted

Tell us what’s happening:
So the tests are all passed, except for the last one, “The sum function uses the … spread operator on the args parameter”. I clearly am using the spread operator, results are fine, why the FCC validator is so mean to me?

Your code so far

const sum = (...args) => args.reduce((a, b) => a + b, 0);
console.log(sum(1, 2, 3)); // 6

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:

1 Like

Looks like it can’t check the code properly if you used an arrow function.

But there is a strong emphasis on using the fat arrows in the course, it was literally introduced and heavily suggested like a couple exercises prior to current one. I’m confused. Also, why in the default function IIFE is used? I see no logical reason behind it.

The fat arrows don’t replace the function declaration syntax, but yes it is confusing, doubly so with the IIFE; you can delete all of that, write function sum(...args) { etc and it works fine.

I hadn’t really looked through the new curriculum in detail, but those are definitely issues; it should work with either function myFunction or cont myFunction =, or warn if it doesn’t, but unfortunately there are going to be usability bugs at this point in time.

1 Like

Thank you, it is working with your suggestion!

There are, in fact, a couple of weird IIFE cases in the ES6 course that are not needed, I’ve just deleted them and it worked fine.