Global/Local Variables code not working?


I am stuck on this lesson. I believe I understand it and I've followed the instructions but I cannot progress as the code fails to work and I cannot understand why.

I've searched and read many other discussions. I've tried to copy/paste answers others have given, but I see no difference in their code vs mine.

Here is my code.

var my_number = 7; //this has global scope

var timesTwo = function(number) {
    var my_number = number * 2;
    console.log("Inside the function my_number is: ");


console.log("Outside the function my_number is: ")


Your missing a semicolon right there. Also, if that doesn't make it work then could I see a link to the exercise?


This discussion also explains Global vs Local very well if there is still confusion. Several people gave detailed explanations in it.


Thank you! This was driving me mad.


np, I'm glad to help :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.