Understanding IIFE

Tell us what’s happening:
I just wonder why the first code is not passing the challenge The function should be anonymous. while the second is passing. Can anyone explain it to me?

Your code so far
Code 1:

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

Code 2:

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:

Both are correct, technically. But maybe the challenge is specifically asking you to use the “function” keyword instead of an ES6 arrow function. IDK if this lesson/challenge comes after or before ES6.


Yes, both functions produces the same result. That’s why I’m asking.

I’m looking for info in web, if I find something I will share here :slight_smile:

I’m not sure if this is correct but sometimes the test suite in FCC’s server checks not just the output (or at all) but rather parts of the written code. You could technically produce the same output with a direct call of console.log but it’s not what the challenge is about.

I’ve been looking for the answer in the web. What I have found is the following:

So, my guess is that arrow functions can be used for IIFE, and the problem that has raised within this specific lesson should be related to how the FCC performs its check.

1 Like