Global vs local variables


Iam having problems understanding the global scope and local scope


If your program has 1 or more funtions in it and if those functions use variables confined to the function only, that's a local variable to the function and not accessible from anywhere else in the program.
If you have variables declared in the program, generally, before you have any other code in the program, they will be global variables for the program.
This is a very superficial explanation.


How would you go about the exercise?


Are you asking for a code example ?


Yes the code that invloves var my_number = 7


You can google your question and get some far better examples


Let's start by determining execution context of command line code. It will be window, the global window context.

var a, b, c;
console.log(this.a, this.b, this.c);
// undefined undefined undefined

Notice there is no ReferenceError? this in the current context is window, the context in which we declared the properties, a, b, and c.

Mull this over for a minute, and ping this topic for more discussion...