JavaScript Switch statement case ?

Sunny.Sagar
Posted by Sunny.Sagar under JavaScript category on | Points: 40 | Views : 1311
<body>

<p id="Example"></p>

<script>
var day;
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
}
document.getElementById("Example").innerHTML = "Today is " + day;
</script>

</body>

Comments or Responses

Login to post response