Set Default Parameters for Your Functions : function inside parenthses?

Tell us what’s happening:

i really don’t understand why we put all of the function inside a parentheses than we call the function with an empty parentheses ???

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:

That is called an IIFE or Immediately Invoked Function Expression. It is an advanced technique - I’m not sure why it is here. There are some issues with the curriculum like this that are being slowly addressed.

1 Like