"Basic JavaScript: Local Scope and Functions"

Hello Guys!

I have got stuck in this challenge. I would really appreciate it if someone could give me a bright light! :sweat_smile:

Thanks in advance!

C.B.

Your code so far


function myLocalScope() {
'use strict';

// Only change code below this line

console.log('inside myLocalScope', myVar);
}
function myLocalScope() {
var myVar = "foo";

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

// Run and check the console
// myVar is not defined outside of myLocalScope


Your browser information:

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

Challenge: Local Scope and Functions

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/local-scope-and-functionsPreformatted text

In what way are you stuck?

1 Like

Hi ArielLeslie!

That is the question. I wasnโ€™t supposed to be stuck on it. I did the same in the video. I removed the part that was saying that โ€˜myVarโ€™ was outside. Maybe should be the value of 'var myVar = โ€œfooโ€; โ€™ ?

What do the instructions tell you to do? What do the failing tests say?

This part: You should add a local myVar variable.

Why did you create a second myLocalScope function inside the one that was provided?

1 Like

I got it! Thanks sooooo much! :blush: