I need help with Local Scope and Functions

Tell us what’s happening:

can someone please help me with this?

Your code so far


function myLocalScope() {

// Only change code below this line

console.log('inside myLocalScope');
}
myLocalScope();

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15.

Challenge: Local Scope and Functions

Link to the challenge:

Click the ‘Reset All Code’ button to start over fresh. Do only what the instructions ask you:

Declare a local variable myVar inside myLocalScope and run the tests.

I’m assuming you know how to declare a variable? So do that inside of the myLocalScope function (right below the comment that says to only change code below this line), run the tests, and look at the output below.

P.S. I’ll add that while the instructions only say to “declare” a variable I would suggest you also assign it a value as well as this will help make the test output clearer.

1 Like

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