Java script supports conditional statements like if, else if and else.

if syntax:

if(boolean-expression)
{
 //set of javascript statements;
}

else if syntax:

else if(boolean-expression)
{
 //set of java script statements
}
Note: 1. one or more else if statement are allowed when there is an associated if statement. 2. else if statements are not allowed without having an associated if statement. 3. There can be more than one else if statement per if statement.

else syntax:

else
{
 //set of javascript statements.
}
Note: 1. only one else statement is allowed per if statement. 2. curly brackets are not necessary whenan if or else if or else statement is having only one statement.

Java script Example for if, else if and else:

The following example displays day name for the passed day number.
  <html>
  <head>
  <title>Javascript if else if and else example</title>
  <script language="javascript" type="text/javascript">
   functionDisplayDayName(dayno) {
   if (dayno==1)
   alert('Monday');
   elseif (dayno==2)
   alert('Tuesday');
   elseif (dayno==3)
   alert('wednesday');
   elseif (dayno==4)
  alert('thursday');
   //so on
  else
  alert('sunday');
  }
  </script>
  </head>
  <bodyonload="DisplayDayName(3)">

   </body>
   </html>