Tell us what’s happening:
Did not get what’s wrong am I doing, It’s saying: You should add a local myVar
variable.
function myLocalScope() {
var myVar = 5;
// Only change code below this line
console.log(‘inside myLocalScope’, myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(‘outside myLocalScope’, myVar);
Your code so far
function myLocalScope() {
var myVar = 5;
// Only change code below this line
console.log('inside myLocalScope', myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log('outside myLocalScope', myVar);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.
@babu1 hi there,
You should not set a number for your local var which is “var myVar” here.
The aim of the course is to understand the difference between local variables and global variables. you don’t need the define amount for the variable here.
You should simply add var myVar as a local variable.
it should look like this:
function myLocalScope() {
'use strict';
var myVar
// Only change code below this line
console.log('inside myLocalScope', myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log('outside myLocalScope', myVar);
the issue for the tests was that you deleted 'use strict';
if that was not deleted, it worked also with var myVar = 5;
when there is a line like // Only change code below this line be sure to respect it or the tests will have issues