Conditions
-
Evaluates an expression, performs action based on that expression.
-
if statement is one of the most common.
-
Use with curly braces most of the time, optional for one line.
-
Trust me, use curly braces all of the time.
if (day == "Saturday")
{
document.write("I am off to Woody's to have
a Grolsch!");
}
-
else and else if (optional) follows the if, and is evaluated
if the if condition is false.
if (day == "Saturday")
{
document.write("I am off to Woody's to have
a Grolsch!");
} else if (day == "Friday") {
document.write("I am off to Christie's to grab
a Hudy Delight.");
} else {
document.write("Back to work(s)");
}
Conditional Operation
Home
Internet II: Day 2