Local scope and functionsss

Tell us what’s happening:

Your code so far


function myLocalScope() {
'use strict';

// Only change code below this line

console.log('inside myLocalScope', myVar);
}
myLocalScope(
var "myVar");

// 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 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0.

Challenge: Local Scope and Functions

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

Hii,

kindly assist me in this topic because i didnt understand the question literally.

What question? You don’t understand the information in the course?

Variables which are declared within a function, as well as the function parameters have local scope. That means, they are only visible within that function.

This means if, in your program, you declare const number = 1, the variable number will be accessible from anywhere in your code.

If you do something like declare function numbercounter(), and you declare const number = 1 inside the function, only this function will ever be able to interact with that variable.

1 Like