**Tell me what's happening with function bracket: (); **

**Tell me what’s happening with function bracket: (); **

Your code so far


const increment = (function() {
  "use strict";
  return function increment(number, value) {
    return number + value;
  };
})(); // <= This is function bracket i don't understand

console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns 6

This is an example of an Immediately Invoked Function Expression (IIFE):

You don’t need to worry about it here, just ignore the outer function, it’s just used as part of testing your code and will be removed in a later version of FCC

2 Likes

@gebulmer is right, though this time around it’s a bit complex because the parent function was invoked (called) on the fly which then returns a function and the function gets assigned to the variable increment. what you called console.log(increment(5, 2)) is the result of the parent function that was executed on the fly. perhaps you should read more on IIFE as I think it will go a long way.

1 Like