Global vs. Local Scope in Function

Tell us what’s happening:
Add a local variable to a function to override a value

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;



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0.

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

Add a local variable to myOutfit function to override the value of outerWear with "sweater" .

to override a variable you need to use the exact name of the variable. In this case the variable outerWear is not used again after its initialization. Try considering this and try again

This assignment is, in my opinion, using some weird terminology, it seems to be sending mixed signals. You can not override a value and not change it. Overriding implies reassignment.

Add a local variable to myOutfit function to override the value of outerWear with “sweater”.

Do not change the value of the global outerWear

Now i will say I’m having a bit of a hard time coming up with a better description for the steps to take, so there is that. For one, it’s just difficult and second, it’s hard to know how exact a terminology to use at this point in the learning process. But i think it’s important to get the correct terminology in place as soon as possible, otherwise, it makes technical communication difficult.

Here is one version i came up with.

Declare a new local variable outerWear scoped to the myOutfit function, assign it the string "sweater" and return it from the function.