Can anyone explain the Rest Operator with Function Parameters?

Tell us what’s happening: Soooo I understand the rest operator somehow but I don’t understand what () is for after } on line 6

Your code so far

const sum = (function() {
  "use strict";
  return function sum(...args) {
    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/72.0.3626.121 Safari/537.36.

Link to the challenge:

1 Like

You can read about IIFEs in another challenge. This and about 5 other challenges are currently being modified to remove the IIFEs, because they are no longer needed to make the tests work in the ES6 section, due to some refactoring in the core curriculum testing code.


Thank you for asking, I was wondering the same.

Ah! Thank you so much. :smiley: