Understand the Immediately Invoked Function Expression (IIFE)

Understand the Immediately Invoked Function Expression (IIFE)
0

#1

Tell us what’s happening:
The below code is failing with error “the function should be anonymous”.

However, it runs perfectly well in node.js and is, I believe, a valid use of the new ES6 arrow function.

Your code so far


(  () => {
  console.log("A cozy nest is ready");
})();


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife


#2

Yes you are correct that your code is an IIFE using arrow function syntax, but the tests are not expecting arrow function syntax. You can check Github to see if anyone has brought up this issue before and create a new issue if it has not.


#3

Tell us what’s happening:

Directions: Rewrite the function makeNest and remove its call so instead it’s an anonymous immediately invoked function expression ( IIFE ).

Quesiton: Can you provide me with some hints in order to solve the exericise? But first, how do I remove the function’s call?

Your code so far


(function () {
  console.log("A cozy nest is ready");
})(); // this is an anonymous function expression that executes right away?

makeNest(); 

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife


#4

Just delete the call of makeNest(); (i.e. just delete makeNest(); )

Edit: Otherwise your code is correct.


#5

(: Thank you kindly fellow camper.