Needing a little help with Java Script

I have gotten most of the way through the challenge. IT says that there is no No global myVar variable

code so far

var globalVar = “I am global!”;

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

console.log(myVar, globalVar);
var myVar = “I am inside another function”;
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar, globalVar);

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

For your variable to be global., it must exist outside of all functions.

Your variable myVar exists inside a function.

There is one exception:
If you don’t use var and assign the variable to a value,. it will update your variable globally.

Remove (or comment out) the variable and console.log() you have outside the function.

Remove the lines:

var myVar = "I am inside another function";
console.log(myVar, globalVar);

That helped. I looked at it right after I did that and it worked like a charme

1 Like