I am so beyond confused on this part it’s not even funny so can some please explain to me exactly what I am suppose to do and then tell me why what I am doing is wrong?
Instructions
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.
function myLocalScope() {
'use strict';
var myVar = "Hello";
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
// Now remove the console log line to pass the test
I get two different errors when doing this.
-
global myVar is not defined but it never says to make a global variable in the instructions
If I were to make a global myVar variable it would look just like this right?
myVar = “5”; -
Reference Error: myVar is not defined.
But didn’t I define it?
var myVar = “Hello”;
Isn’t creating the variable and assigning it the value of Hello defining the variable?
I am so utterly confused at this point.
EDIT I passed the challenge by deleting:
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
// Now remove the console log line to pass the test.
But I am still confused on this whole thing though I feel I passed the challenge purely on luck