The value of the variable name3 is 'Newton' on the global level and 'Einstein' on a local level. The last alert box displays 'Newton' because it is calling the global variable called name3. The second alert box contains 'Einstein' because it is calling the function where name3 is declared 'Einstein'. In other words local variables take precedence over global variables when you are in the local function. If we call global variables inside of a function when we don't have a variable of the same name inside that function, then the global value will be used.
Intro to Forms Exercise | Global and Local Variables Exercise | Functions Exercise
Created by: Laura Shears
e-mail: fakeEmail@fakeBusiness.com
my CITW 165 home page