// Setup
var outerWear= "sweater";
function myOutfit() {
// Only change code below this line
var outerWear= "sweater";
// Only change code above this line
return outerWear;
}
myOutfit();
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.
Challenge: Global vs. Local Scope in Functions
Link to the challenge:
You should not change the value of the global outerWear . How???
This exercise is trying to explain to you how global scope works.
You are initialising the outWear var twice. Once outside of the function and once inside.
What part of the challenge description can I clarify? If you declare the same variable both as a global variable and a local variable inside a function, the local definition overrides the global value inside of the function.
// Setup
var outerWear = "T-Shirt"; // <- DO NOT CHANGE THIS
function myOutfit() {
// Only change code below this line
// THIS IS THE ONLY PLACE WERE YOU SHOULD MAKE CHANGES
// Only change code above this line
return outerWear;
}
myOutfit();