Can't get past this question [Solved]

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


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.

1 Like

Thanks. That solved it.