else if

else if executes when an alternate condition is true.

Multiple else if statements are allowed.

The else statement is optional.

Syntax

if (condition1) {
  code
} else if (condition2) {
  code
} else if (condition3) {
  code
...
} else {
  code
}

Example | True

Example | False

External

Mozilla Developer Network