JavaScript if/else statements

JavaScript have the following conditional execution in the forms of if..else statement

  1. if statement: if the condition is true, run the block

2. if…else statement : if the condition true, run the if block. if false then run the else block

Example Code:


x is greater than 5

3. if..else if..else : check for all condition , whatever condition become true run the respective block and exit. if all condition false , run the else block by default.

Example Code:

Output: x is greater than 5 and less than or equal 10

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top