Basic JavaScript - Local Scope and Functions

Tell us what’s happening:
I am confused how to add the (.loc) here. It doesn’t make sense to me…

Your code so far



function myLocalScope() {


console.log(myVar);
}
myVar = myLocalScope(myVar);


  console.log(myVar);
}
myLocalScope(loc);

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log('outside myLocalScope', myVar);

Your browser information:

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

Challenge: Basic JavaScript - Local Scope and Functions

Link to the challenge:

The only thing the instructions are asking you to do is declare a new variable called myVar inside the myLocalScope function. You can assign it a value if you like. Other than that, do not make any other changes to the code. I would restart the lesson to get the original code back and then only add the myVar variable as instructed.

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