If else if statement:
The
if...else if... statement is the one level advance form of
control statement that allows JavaScript to make correct decision out of
several conditions.
Syntax:
if (expression 1)
{
Statement(s) to be executed if expression 1 is true
}
else if (expression 2)
{
Statement(s) to be executed if expression 2 is true
}else if (expression 3)
{
Statement(s) to be executed if expression 3 is true
}else
{
Statement(s) to be executed if no expression is true }
}
|
There is nothing special about this code. It is just a series of
if
statements, where each
if is part of the
else clause of the
previous statement. Statement(s) are executed based on the true condition, if none
of the condition is true then
else block is executed.
No comments:
Post a Comment