Tell us what’s happening:
Describe your issue in detail here. myOutfit should return the string sweater .
My code does not show “sweater” in console.
It shows t-shirt, and it also lets me pass the challenge even though it shows the wrong string. How can I fix this?
Your code so far
// Setup
const outerWear = "T-Shirt";
function myOutfit() {
// Only change code below this line
const outerWear = "sweater";
// Only change code above this line
return outerWear;
}
myOutfit();
console.log(outerWear);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Global vs. Local Scope in Functions
I’m very new at javascript so sorry if i’m abit slow to understand, but is it possible to log a function in console? if I use console.log(myOutfit); for example it’ll only show “[Function: myOutfit]”
To clarify so you understand, I wanna console.log this out so it returns “sweater”. Or am I not supposed to do that in this challenge? Because it says that the local variable should have precedence over the global variable, but it shows the global variable when i try to console.log it