Tell us what’s happening:
Describe your issue in detail here.
When I remove var from oppsGlobal I only pass the 3rd point( myGlobal should be declared using the let or const keywords).
When I add var to oppsGlobal I pass all 3 but fail the last( oopsGlobal should be a global variable and have a value of 5)
i am confused and not sure what I’m not doing correct, any assistance will be appreciated.
**Your code so far**(with my code as it is below i pass 3/4)
// Declare the myGlobal variable below this line
let myGlobal = 10;
function fun1() {
// Assign 5 to oopsGlobal Here
var 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;
}
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/98.0.4758.102 Safari/537.36 Edg/98.0.1108.56
Inside function fun1 , assign 5 to oopsGlobalwithout using the let or const keywords.
This is the relevant code:
function fun1() {
// Assign 5 to oopsGlobal Here
var oppsGlobal = 5;
}
First of all, you misspelled the variable name. And, don’t use var. We should never use var. The point of the exercise is that if you create the variable without declaring it, it will have a global scope - almost always a bad thing.
HI, thanks for your reply, I used var to see what happens when i run the test , because when I run the test without var i only pass the 3rd point but when I use var i pass the first 3 points in the test , which is confusing to me.
Thanks for pointing that spell error, been busy with it for almost an hour can’t believe I killed myself like that with a spelling error.
Think I need to take a break and breath and then get back on the wagon.
Thank you for taking the time to reply , sometimes we need outside eyes to point out mistakes we miss because of being overwhelmed and overthinking to much.
Much Appreciated @kevinSmith.
Trust me, that’s just part of coding. When you get to “real” coding, things like linters and spell checkers in you editor can catch a lot of those. But “silly mistakes that drive me crazy” will never go away completely.