Im new and stuck

I seem to be stuck?

function myLocalScope () {

  'use strict';

  // Only change code below this line

var myVar = 5;




// Run and check the console

// myVar is not defined outside of myLocalScope

console.log('outside myLocalScope ', myVar);
ReferenceError: myVar is not defined

Run test and doesnt pass. Even though the 5 is clearly local and isnt define outside.

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:

Your code is fine and passes for me. Which one of the tests is it failing?

1 Like

I’d recommend clearing your cache or trying a different browser. I am intermittently getting failures from your code.

1 Like

You should add a local myVar variable. isnt passing on mine. I’ve been trying stuck for an hour, copy and pasting everyones code from the hints and still doesnt pass. :frowning:

Lets go through this line by line.

You’re declaring a function called myLocalScope

Then you’re running the myLocalScope

  'use strict';
// not sure what you're trying to do with use strict

var myVar = 5;
// setting a variable called myVar to 5

// logging to console the myVar variable which is equal to 5

All in all this function returns nothing, all its doing is establishing a variable and logging that variable to the console. In order for you to “see” this variable outside of this “local scope” you’ll need to return myVar inside it.

console.log('outside myLocalScope ', myVar);

this is the last line of your code, myVar does not exist in the Global scope. myVar only exists within the function

I was doing this on firefox, so tried Chrome and it worked annoying! been pulling my hair out haha. Thank you all!! <3

1 Like

Welcome to the wild world of web development and browser compatibility.

Strange thats the only question not to work so far on FireFox.