Switch based on integer value : Switch « Language Basics « JavaScript DHTML






Switch based on integer value

 

<HTML>
<BODY>
<H1>
   <SCRIPT>
var n = 1;
switch (n) {
case 1: {
     document.write("n equals 1");
     break;
}
case 2:{
     document.write("n equals 2");
     break;
}
case 3:{
     document.write("n equals 3");
     break;
}
default:{
     document.write("No match!");
     break;
   }
}

   </SCRIPT>
</H1>
</BODY>
</HTML>

   
  








Related examples in the same category

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