HTML and CSS Reference
In-Depth Information
Exercises
1. Create a while loop that displays numbers as: 10 9 8 7 6 5 4 3 2 1. Put the
numbers in HTML table cells.
2. Ask the user what the current hour is. If the hour is between 6 and 9 a.m., tell
the user, “Breakfast is served.” If the hour is between 11 a.m. and 1 p.m., tell
the user, “Time for lunch.” If the hour is between 5 and 8 p.m., tell the user,
“It's dinner time.” For any other hours, tell the user, “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 lan-
guage. Alert the user when he or she is wrong, and then keep asking the user
until he or she gets the correct answer. When the user gets it right, confirm it.
5. Use a switch statement to rewrite the following JavaScript code. Prompt the user
for the number of a month rather than setting it to 8.
<script type=text/javascript>
month = 8;
if (month == 1) {
alert("January");
}
else if (month == 2) {
alert("February");
}
else if (month == 3) {
alert("March");
}
else if (month == 4) {
alert("April");
}
else if (month == 5) {
alert("May");
}
Search WWH ::




Custom Search