Basic JavaScript: Global Scope and Functions Troubles on Assignment

Tell us what’s happening:
Can someone please tell me what I did wrong…?
I checked the video, the hint, and even the solution…
And I believe I have the same answer as the solution also, but
it just won’t let me pass…
When I run the test, it keeps returning
// running tests
myGlobal should be defined

myGlobal should have a value of 10

oopsGlobal should be a global variable and have a value of 5

// tests completed
// console output
ReferenceError: oppsGlobal is not defined"

Your code so far

// Declare the myGlobal variable below this line
var 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;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Global Scope and Functions

Link to the challenge:

Check the spelling of your variable names again. It has to be exactly the same as in the instructions (myGlobal and oopsGlobal).

Thank you so much.
I directly copied-paste the name,
and its now good ><!
Thank you

omg this is so weird!

I was having the same problem and I retyped it three times. Still, it won’t let me pass.
And when I was looking at your code too, I couldn’t see any typing error!

So glad copy-n-paste worked and fixed everything

1 Like