Local Scope and Functions (refresh not working)

Tell us what’s happening:
So I figured out this first checkmark (Add a local myVar variable) but I can’t figure out how to do “No global myVar variable” I’ve looked through and there a few forums like this but the answers weren’t clear. Basically, they say after you have the first checkmark, refresh, delete “console.log(myVar);” and you should have it. I have tried it with both console logs but mainly the first one. Should I be doing it with the second one or is the first one right? Am I refreshing out of order or something? Anyway, thanks for reading. All your clarification is appreciated!

Your code so far


function myLocalScope() {
  'use strict'; // you shouldn't need to edit this line
  

console.log(myVar);
}
myLocalScope();
var myVar = "strict";
// 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/67.0.3396.87 Safari/537.36.

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

Yea I thought that but when I make it:

function myLocalScope(myVar = “strict”) {
‘use strict’; // you shouldn’t need to edit this line

console.log(myVar);
}
myLocalScope();

It doesnt work.

I keep looking back at the example:

Here is a function myTest with a local variable called loc.

function myTest() {
var loc = “foo”;
console.log(loc);
}
myTest(); // logs “foo”
console.log(loc); // loc is not defined

So wouldnt this be the same as me saying:

function myLocalScope() {
‘use strict’; // you shouldn’t need to edit this line
var myVar = “strict”;
console.log(myVar);
}
myLocalScope();

I dont understand what the difference is other than labels.

the first code was not mine, it was the example of what a local variable should look like. I was wondering what the difference was between that and what mine says. Based off that I should be getting the “Add a local myVar variable” check mark. I am defiantly the reason you are confused, I’ve just been stuck on this problem for almost an hour now and even when I try to directly copy someone else solution I can’t complete it and i’m starting to get frustrated.

So after experimenting and going through other tests about functions i finally got the solution. What i did was have:
var myVar = “strict”;
function myLocalScope() {
‘use strict’; // you shouldn’t need to edit this line
var myVar = “strict”;
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

Then I refreshed and deleted:
var myVar = “strict”; (one nearest to the top of the screen)
and both console.log(myVar);

I was way overcomplicationg things. I wast trying to add and change way to many elements and was’nt pinpointing the main question. Im still not 100% sure on why I needed to refresh and remove lines of code however. Anyway, you really did help and I am reliefed to move on!