10/13


#1

var my_keyword = 7; //this has global scope
var timesTwo = function(number) {
my_number = number * 2;
console.log("Inside the function my_number is:14");
console.log(my_number); // 14
};

timesTwo(my_number);

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


#2

Hi, put just a literal number in timesTwo() function as follows.

timesTwo(2);

And, put var at this line.


#3

it keeps saying to put a 'var' keyboard what should i do there


#4

You need to put a var before the my_number variable in your timesTwo function. What you should see now is that by redeclaring it in a local scope you created another variable with the same name but not connection to the one outside of the function and that the variable outside of the function is now no longer accessible from inside (although it is global).


#5

@designninja16000,

You begin with
var my_keyword = 7;
change that into
var my_number = 7;

===========================

var my_number = 7; //this has global scope 
var timesTwo = function(number) {
    var my_number = number * 2;
    console.log("Inside the function-scope local my_number is:14");
    console.log(my_number); // 14 
    console.log("Inside the function-scope global my_number is:7");
    console.log(window.my_number); // 7
}; 

timesTwo(my_number);

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

#6

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(my_number);
};

timesTwo(7);

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


#7

@meganinja13726,
Your code is Ok.
I tried it in a windows 8.1 IE11 envorinment and got a pass...
Maybe...
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).