Basic JavaScript - Global Scope and Functions

Tell us what’s happening:
Describe your issue in detail here.

FIXED by coping the oppsGlobal from the if statement, there seems to be something wrong with typing oppsGlobal but worked when i replaced with the copy.

  **Your code so far**
// Declare the myGlobal variable below this line
let myGlobal = 10;
oopsGlobal = 5;

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

// 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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Global Scope and Functions

Link to the challenge:

You are not supposed to declare oopsGlobal. Just don’t declare it, but assign it the value inside the function.

function leaking() {
  onGlobalObject = 'Breaking bad';
}

leaking();

console.log(onGlobalObject); // Breaking bad
// In the browser
console.log(window.onGlobalObject); // Breaking bad
// In Nodejs
console.log(global.onGlobalObject); // Breaking bad