LABAR Project 9
This
assignment is to be done during your one hour lab by arrangement
(LABAR). This assignment requires you to create a javascript function to take in two variables and print the difference if the first one is larger, else print the sum:
Step 1 - declare two number variables: var1 and var2;
Step 2 - prompt and obtain the value of var1 then var2 (one at a time) and print both variables on the screen;
Step 3 - if the var1 is greater than var2 , then print the difference of var1 and var2, else print the sum of var1 and var2.
And use an html tag onclick attribute to envoke this javascript function.
Note: The following envelope HTML code has to be included for the .html file in order for your javascript to execute correctly:
Example
The following javascript example can be found on the PL's note p.11
Click the button to execute the sample javascript:




No response to “Assignment 9 - Javascript Decision Statement and Input Box (PL's note js p.10 - 14)”
Post a Comment