function myLocalScope () {
'use strict';
// Only change code below this line
var myVar = 5;
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log('outside myLocalScope ', myVar);
5
ReferenceError: myVar is not defined
Run test and doesnt pass. Even though the 5 is clearly local and isnt define outside.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0.
You should add a local myVar variable. isnt passing on mine. I’ve been trying stuck for an hour, copy and pasting everyones code from the hints and still doesnt pass.
'use strict';
// not sure what you're trying to do with use strict
var myVar = 5;
// setting a variable called myVar to 5
console.log(myVar);
// logging to console the myVar variable which is equal to 5
All in all this function returns nothing, all its doing is establishing a variable and logging that variable to the console. In order for you to “see” this variable outside of this “local scope” you’ll need to return myVar inside it.
console.log('outside myLocalScope ', myVar);
this is the last line of your code, myVar does not exist in the Global scope. myVar only exists within the function