Tell us what’s happening:
Describe your issue in detail here.
Good morning to all my bosses and friends.
I did this already and the code passed but I have a problem with how this works.
Take a look at the code below as used in the previous example. The function myFun(); should return “Head” but it’s returning nothing after a series of test.
const someVar = “Hat”;
function myFun() {
const someVar = “Head”;
return someVar;
}
myFun();
This is why I’m worried.
It returns nothing when I tested the code with Js Run
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();
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36
Challenge: Basic JavaScript - Global vs. Local Scope in Functions
In the previous code, there are two variables that share the same name but have different roles. One is global in scope, and the other is local.
run this code so you can understand the differences: