Basic JavaScript - Global Scope and Functions

This is what I input I don’t understand what is wrong

// Declare the myGlobal variable below this line
let myGlobal = 10;

function fun1() {
  // Assign 5 to oopsGlobal here
  oopsGlobal = 5;
}

// Only change code above this line

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

Your code passes for me. Can you be more specific about what is happening on your end? Are you getting any error messages?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.