Another switch Statement : Switch « Language Basics « JavaScript DHTML






Another switch Statement

  
<HTML>
<HEAD>
<TITLE>Using the switch Statement</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript"><!--
for(i=1; i<=10; ++i) {
 switch (i) {
  case 1:
   val = "one"
   break;
  case 2:
   val = "two"
   break;
  case 3:
   val = "three"
   break;
  case 4:
   val = "four"
   break;
  case 5:
   val = "five"
   break;
  case 6:
   val = "six"
   break;
  case 7:
   val = "seven"
   break;
  case 8:
   val = "eight"
   break;
  case 9:
   val = "nine"
   break;
  case 10:
   val = "ten"
   break;
  default:
   val = "unknown"
 }
 document.writeln(val+"<BR>");
}
// -->
</SCRIPT>
</BODY>
</HTML>

           
         
    
  








Related examples in the same category

1.Switch statement
2.The 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