Global Vs. Local Variables


#1

I am just not completely understanding what they are asking so I'm not sure how to get past this lesson. I understand that there is the global variable written but what exactly are they asking me to put inside of the function. I'm getting confused with their use of 'keyword'.

var my_number = 7; //this has global scope

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

timesTwo(7);

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

#2

var is a keyword, without it, my_number inside the function will overwrite the global variable


#3

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