Basic JavaScript - Global Scope and Functions

what can be the problem?

Is there anything I’m missing here in this code…?

Below is my code

// Declare your variable here;
var myGlobal = 10;

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


    // Only change code above this line
    function fun2() {
      var output = "10";
        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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Mobile Safari/537.36

Challenge Information:

Basic JavaScript - Global Scope and Functions

Hello @Zedrick2022 !

The first variable is the problem. The instructions ask us to use a different variable for myGlobal. You may wish to look at that again.
That is the only problem.

Keep up the good progress and happy coding!

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