Object Oriented Programming - Understand the Immediately Invoked Function Expression (IIFE)

While this code works well as a solution to the exercise, it does not work in my VScode/terminal and I have tried all forms of solution online , like using window.console.log() and global.console.log().

I keep getting the error console.log(…) is not a function…

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

Your browser information:

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

Challenge: Object Oriented Programming - Understand the Immediately Invoked Function Expression (IIFE)

Link to the challenge:

Thank you for your response.

I figured I was getting the error because I had previous lines of code I didn’t end with the semi-colon, “;”.

When I copied the small code into a new file, to run and get the snap shot of error for you, it ran fine.

Going back to the other file and adding the ending semi-colon “;”, it ran without errors.
So, I guess one has to have all necessary lines ended with the semi-colon to avoid the TypeError: console.log(…) is not a function.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.