<
start
>
clear
copy to:
0
insert
save as:
new page
new last
delete
CSC 130
Control Flow
A program can be thought of like a recipe. The program is read by the computer from top to bottom. Consider this set of statements: var num1 = 3; var num2 = 4; var num3 = num1 + num2; alert(num3); The computer executes each statement above in order, first assigning the numbers to variables and then adding them, assigning the result to a new variable and then outputing it. Compare that to this: var num3 = num1 + num2; var num1 = 3; var num2 = 4; alert(num3); Notice that the output now is "NaN"? This is because when num1 and num2 are added together and then the result assigned to num3, they hadn't yet been defined. Order can be important!