Can't get past this question [Solved]

Can't get past this question [Solved]
0

#1

Hi I’m trying to do the JS question entitled “Local Scope and Functions”. It says I need to uncomment the console log line, but it still doesn’t let me advance. Any advice?

function myLocalScope() {
  'use strict';
  myVar="test";
  
  console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope


// Now remove the console log line to pass the test



#2

You need to append the var keyword before myVar. The 'use strict' at the top of the function specifically prevents people from declaring variables without the var keyword.


#3

Thanks. That solved it.