Local Scope and Functions NEWBIE PROBLEMS

Tell us what’s happening:

Your code so far


function myLocalScope() { var myVar = '';}
  'use strict'; // you shouldn't need to edit this line
  
  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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/local-scope-and-functions/

Hi
Just follow the instruction
and write your code in the reserved area
there is no magic :

function myLocalScope() {
  'use strict'; // you shouldn't need to edit this line
  var myVar ;
  console.log(myVar);
}
// Run and check the console
// myVar is not defined outside of myLocalScope
// Now remove the console log line to pass the test
1 Like