Javascript local

add the myVar in local

Your code so far


function myLocalScope() {
'use strict';

// Only change code below this line
myVar= 5;
console.log( myVar);
}
myLocalScope(myVar);

// Run and check the console


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36.

Challenge: Local Scope and Functions

Link to the challenge:

You need to add the local variable, local variables are those variables which are in function.

You are using myVar but no declaring anywhere so you need to declare it in function like this: var myVar = 123;

1 Like

Thanks for your explanation