Local Scope and Functions - Am I missing something?

Hi everyone! :slight_smile:

So, the problem asks us to declare a local variable named myVar inside of myLocalScope.

Before submiting the test, the logs shows :
inside myLocalScope 3
ReferenceError: myVar is not defined

Leading me to believe that my var is declared localy since it can not be detected by the console.log outside of myLocalScope function.

After submitting the test, this is the log :
// running tests You should add a local ‘myVar’ variable.
// tests completed
// console output SyntaxError: invalid regular expression flag s

Am I missing something? Don’t I already have a local variable if the first line of the first log returns the value of myVar? I’ve reset the code, retyped it multiple times, reopened my browser (yeah, I don’t know…) I don’t get where I went wrong. Could someone beat the stupid out of me please? >.<

My code so far

function myLocalScope() {
'use strict';

// Only change code below this line
var myVar = 3;
console.log('inside myLocalScope', 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:76.0) Gecko/20100101 Firefox/76.0.

Challenge: Local Scope and Functions

Link to the challenge:

It looks like there might be a typo in the test script. Just use the curriculum map on /learn to move on to the next lesson;

It seems to be working fine on my end.

It’s working for me on Chrome but not Firefox.

Ok, thank you! The browser must be at fault, I’m on Firefox indeed.

Glad I’m not going crazy.

1 Like