Global vs. Local Scope in Functions

Global vs. Local Scope in Functions
0

#1

Tell us what’s happening:

Your code so far


// Setup
var outerWear = "T-Shirt";

function myOutfit() {
  // Only change code below this line
  var myOutfit = "sweater";
  
  
  // Only change code above this line
  return outerWear;
}

myOutfit();

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/global-vs--local-scope-in-functions


#2

I can see the confusion here. Let’s try to clear that up:

  1. myOutfit is not the variable name you want.
  2. var creates a new variable. The challenge wants to you overwrite the variable that already exists.

#3

Always read exercise descriptions and requirements with a clear mindset.

Check your variable names.