The if..else if..else construct is used for processing multiple conditions. Often a better option is the switch statement.

Syntax
if (condition1 is true)
{
statements to be executed if condition1 is true
.........
}
else if (condition2 is true)
{
statements to be executed if condition2 is true
...............
}
else
{
statements to be executed if all the above condition are false
}

<html>
<head>
<title>If else construct</title>
<script>
a = 30
if (a>40)
{
alert("value of a is greater than 40")
}
else if(a < 40)
{
alert("value of a is less than 40")
}
else
{
alert("value of a is equal to 40")
}
</script>
</head>
</html>

So let's select and copy the above code, and experiment.

Nested if's

Table of Contents