IF/ELSE Conditionals
The script that produces the output is easy to understand.
Try to understand the script source code and then read below for further explanation.
An IF/ELSE Conditional works as follows:
if ( boolean expression ) {
JavaScript Statements
}
else {
Alternate JavaScript Statements
}
If the Boolean expression evaluates to true, then the statements in the body {} of the IF statement are executed.
Otherwise the alternate statements in the ELSE {} are executed.
The ELSE clause doesn't have its own Boolean expression.
An ELSE clause can always be used to provide an alternate course of action when an IF condition is false.