Switch statement : Switch « Language Basics « JavaScript DHTML






Switch statement

  
/* Note that Sunday=0, Monday=1, Tuesday=2, etc.*/

<html>
<body>
<script type="text/javascript">
var d = new Date()
theDay=d.getDay()
switch (theDay){
  case 5:
    document.write("Finally Friday")
  break
  case 6:
    document.write("Super Saturday")
  break
  case 0:
    document.write("Sleepy Sunday")
  break
  default:
    document.write("Not weekend!")
}
</script>


</body>
</html>


           
         
    
  








Related examples in the same category

1.The switch Statement
2.Another switch Statement
3. The switch Construction in Action
4.Use switch with true false value
5.Switch with string value
6.Switch based on integer value