Help me to define global

Tell us what’s happening:

Your code so far


// Declare the myGlobal variable below this line
var myGlobal;
myGlobal = 10;
function fun1() {
// Assign 5 to oopsGlobal Here
oppsGlobal = 5;
}

// Only change code above this line

function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
  output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
  output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36/8vfJ8dsw-50.

Challenge: Global Scope and Functions

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.


I think that you have a typo in your variable name.

i add the variable which is required but code is not running
1- define myGlobal
2- myGlobal should have value 10

I think you have a typo in your variable name.

i have add o in oops but still not running

What is your current full code?

thanks the code has been run there is typing mistake
thanks alot

1 Like