Javascript If Else

tutorial and example
tutorial and example

JavaScript use a conditional statement which is used to perform different tasks according to the conditions.

There are three forms of statements use in JavaScript.

  1. if Statement.
  2. if else Statement.
  3. if else if Statement.

if statement

The if statement is used in JavaScript to execute the code if the condition is true or false.

Example:-

Output

if else statement

The if else statement is use for either condition is true of false.

Syntax

Example

Output

If else if

It checks the content only, if expression is true from several expressions. if else if statement is an advanced form of if else statement.

Syntax

Example

Output