JavaScript Control Flow Conditionals

Else if

An if statement can be followed by zero or more else-if statement where each statement can have their own condition and associated code block. JavaScript will continue checking every condition until a truthy one is found and execute its code block.

if (condition) {
// execute the code within this code block
} else if (condition2) {
// code block for condition2
} else if (condition3) {
// code block for condition3
}