The Else if statement in JavaScript
Else if Statement
As we know, an if statement will only execute when the condition inside it is true. Similarly, if the condition is false inside the if block, then the else block will be executed. However, we now have added an else if block in between them to check for multiple conditions, and if the condition is true then that particular else if block will be executed.
Syntax:-
if(condition_1==true){
// code executes
} else if(condition_2==true){
// code executes if the condition above is not satisfied
} else{
// code will execute if both above conditions are not satisfied
}