[Help] Variables created w/o var keyword aren't creating global variables

In the JavaScript algorithms & data structure certification’s tutorial titled “Global scope & functions” , it has been mentioned that " Variables which are used without the var keyword are automatically created in the global scope". But when I tried to run the following code in my laptop using node, then it gave error :

function func()
hw="Hello World!";

I would be glad if someone can help me out :cry:

is the error that you need to declare all variables?

as global variables are usually unwanted side effects, now usually JavaScript run in strict mode that throws errors for undeclared variables