Why is undeclared variable throws an error even in non-strict mode?

Tell us what’s happening:
I’ve read a lot about strict mode in ES6. Based on my understanding it restricts certain behavior and throw an error when a mistake has been done. One typical example is when you forget to declare a variable (with either var, const, or let keyword), you will get an error of “X is not defined”. But even after I removed the “use strict” directive, it still throws the same error in the challenge. So idk how actually did the strict mode make a difference in this case.

Your browser information:

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

Challenge: Explore Differences Between the var and let Keywords

Link to the challenge:

You have no code in your question.

1 Like

By default, the freeCodeCamp editor runs all code in strict mode.

1 Like

Got it! Thanks a million!

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