if-else-if ledder Statement of JavaScript

Card image cap

if-else-if ladder Definition:

The if else ladder statement is an advanced form of control statement that allows JavaScript to make correct decision out of several conditions.

A normal If Statement must be placed before the use the else If Statement. this is because the else if statement is an add-on to the simple if Statement.

if-else-if ladder can decide among multiple options. The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed.

Syntax:

Flow chart:

Example:

Result :

a is the first letter


Read Also:


Card image cap