Global Vs Local Scope in Functions Help

Continuing the discussion from freeCodeCamp Challenge Guide: Global vs Local Scope in Functions:

I cannot find the answer to this problem!

Would someone please help me?

What is your question? What have you tried? What don’t you understand? What is working differently than you expect it to?

I tried this and…

// 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();

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

What do the failing tests say? What is happening that is different from what you expect?

var outerWear = “T-Shirt”;

function myOutfit() {
// Only change code below this line

var outerWear = “sweater”;

// Only change code above this line
return outerWear;
}

myOutfit();

3 Likes

that worked for me thank you very much