Syntax error? ES6 set-default-parameters-for-your-functions

Challenge Name

set-default-parameters-for-your-functions has an issue.

Issue Description

I don’t really have a problem with this challenge. I’m just wondering why are there parenthesis surrounding the function that is assigned to the const increment variable. When I removed them, the test still passed.

Browser Information

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0.

Screenshot

Your Code



const increment = (function() {
  "use strict";
  return function increment(number, value) {
    return number + value;
  };
})();
console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns NaN

It is just another way to write an IIFE ((Immediately Invoked Function Expression)

Thanks for the answer. But I still don’t get this structure…

const increment = (function() {
  "use strict";
  return function increment(number, value = 1) {
    return number + value;
  };
})();

Turns out in this code we have structure like this:
const increment = (two functions inside)();

so there are two pairs of parenthesis… what are they used for? what do they mean?