JavaScript Program to Find Month Of Year Using Switch Case

JavaScript-program-to-find-month-of-year-using-switch-case

JavaScript code:


<HTML>
  <HEAD>
    <TITLE>
    </TITLE>
  </HEAD>
  <BODY>
    <SCRIPT>
    var n=prompt("Enter the month of a year is: ");
    switch(n)
    {
     case"jan":
     document.write("<br>This month is January");
     break;
     case"feb":
     document.write("<br>This month is February ");
     break;
     case"mar":
     document.write("<br>This month is March");
     break;
     case"apr":
     document.write("<br>This month is April");
     break;
     case"may":
     document.write("<br>This  month is May");
     break;
     case"jun":
     document.write("<br>This  month is June");
     break;
     case"jul":
     document.write("<br>This  month is July");
     break;
     case"aug":
     document.write("<br>This  month is August");
     break;
     case"sep":
     document.write("<br>This  month is September");
     break;
     case"oct":
     document.write("<br>This  month is October");
     break;
     case"nov":
     document.write("<br>This  month is November");
     break;
     case"dec":
     document.write("<br>This  month is December");
     break;
     default:
     document.write("<br>Not the month of a year");
    }
   </SCRIPT>
  </BODY>
</HTML>

Output :

Enter the month of a year is:
nov
This month is November.

Post a Comment

0 Comments