Basic JavaScript - Global vs. Local Scope in Functions

Console.log returns “T-shirt” shouldn’t it return “sweater” since the local version of the variable is present.

Your code so far

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

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


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Global vs. Local Scope in Functions

Link to the challenge:

You are only changing the value of that variable inside of the function.

Im confused then as to how the function is ran or accessed ? Can you use console.log on a function?

You can use console.log() to see the return value from a function:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.