Test case failing

Tell us what’s happening:
declare variable with 5, this test case is failing although i have assigned the value 5 only to it.

Your code so far


// Declare the myGlobal variable below this line


function fun1() {
 // Assign 5 to oopsGlobal Here

var oopsGlobal=5;
}

// Only change code above this line
var myGlobal=10;

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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Global Scope and Functions

Link to the challenge:

oopsGlobal shouldn’t be declared using the var keyword since we want it to be global.

function fun1() {
 // Assign 5 to oopsGlobal Here
  oopsGlobal = 5;
}
1 Like