Conditional checking in JavaScript

If-then-else statement

 Syntax:

           If(condition)

{

//Code

}

 

Example:

          Var month=”jan”

If(month==”jan”)

{

Alert(“this is january month”)

}

 

Immidiate Conditional expression:

 Syntax:

(condition)? value1 : value2

 

Example:

Var month=”jan”

(month==”jan”)? “this is january” : “this is not january”