Statements

Executes a set of statements if a specified condition is true. If the condition is false, another set of statements can be executed.

Table 29. If...else statement

Statement

Description

if…else

if executes a set of statements if a specified condition is true. The specified condition may be another statement and can include other nested if statements. Braces, {}, must enclose multiple statements. If the condition is false, another set of statements can be executed if the optional else statement has been included in the script.

A sample if … else statement looks likes this:

if (condition) {

statements1

}

else {

statements2

}