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

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

#1

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


#2

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