It evaluates the content only if expression is true from several expressions. The signature of JavaScript if else if statement is given below.
if(expression1){
//content to be evaluated if expression1 is true
}
else if(expression2){
//content to be evaluated if expression2 is true
}
else if(expression3){
//content to be evaluated if expression3 is true
}
else{
//content to be evaluated if no expression is true
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JavaScript</title>
<script>
/* If Else IF Condition */
var per = prompt("Enter your Percentage : ");
if (per >= 80 && per <= 100) {
document.write("You are in Merit.");
}else if (per >= 60 && per < 80) {
document.write("You are in Ist Division.");
}else if (per >= 45 && per < 60) {
document.write("You are in IIst Division.");
}else if (per >= 33 && per < 45) {
document.write("You are in IIIst Division.");
}else if (per < 33) {
document.write("You are Fail.");
}else {
document.write("Please Enter Valid Percentage.");
}
</script>
</head>
<body>
</body>
</html>