EXERCISES


1:

Create a while loop that displays numbers as: 10 9 8 7 6 5 4 3 2 1.

2:

Ask the user what the current hour is. If the hour is between 6 and 9 a.m., tell him, "Breakfast is served ." If the hour is between 11 a.m. and 1 p.m., tell him, "Time for lunch ." If the hour is between 5 and 8 p.m., tell him, "It's dinner time." For any other hours, tell him, "Sorry, you'll have to wait, or go get a snack ."

3:

Create a conversion table using the following formula:

 
 C = (F  32) / 1.8; 

Start with a Fahrenheit temperature of 20 degrees and end with a temperature of 120 degrees; use an increment value of 5. The table will have two columns , one for Fahrenheit temperature values and one for those same temperatures converted to Celsius.

4:

Ask the user for the name of the company that developed the JavaScript language. Alert him when he is wrong, and then keep asking him until he gets the correct answer. When he gets it right, confirm it.

5:

Use a switch statement to evaluate the menu item selected to produce output similar to what you see below.

graphics/06inf03.jpg




JavaScript by Example
JavaScript by Example (2nd Edition)
ISBN: 0137054890
EAN: 2147483647
Year: 2003
Pages: 150
Authors: Ellie Quigley

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net