Tell us what’s happening:
Describe your issue in detail here.
Can anyone explain to me what the global “outerWear” becomes undefined if a new local variable with the same name is declared after it?
**Your code so far**
var outerWear = "T-Shirt";
function myOutfit() {
console.log(outerWear); //print undefined
var outerWear="sweater";
console.log(outerWear); //prints sweater
return outerWear;
}
myOutfit();
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.
Challenge: Global vs. Local Scope in Functions
Link to the challenge: