HTML and CSS Reference
In-Depth Information
Working with Conditional Statements
• To test a single condition, use the construction
if (
condition
) {
commands
}
where
condition
is a Boolean expression and
commands
is a command block run if
the conditional expression is true.
• To test between two conditions, use the following construction:
if (
condition
) {
commands if condition is true
} else {
commands if not true
}
• To test multiple conditions, use the construction
if (
condition 1
) {
first command block
} else if (
condition 2
) {
second command block
} else if (
condition 3
) {
third command block
…
} else {
default command block
}
where
condition 1
,
condition 2
,
condition 3
, and so on are the different condi-
tions to be tested. If no conditional expressions return the value
true
, the
default
command block
is run.
You now have all of the tools you need to complete the calendar app. The only remain-
ing task involves writing out the table cells containing the calendar days so that they're
organized into separate rows. You'll complete the calendar app in the next section.