Use switch case statement on number - Javascript Statement

Javascript examples for Statement:switch

Description

Use switch case statement on number

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <div id="stars"></div> 
      <script language="JavaScript">
html='';
num=4;/*  www .j  a v  a 2s .c o m*/
switch(num) {
    case 5:
        html+="*";
    case 4:
        html+="*";
    case 3:
        html+="*";
    case 2:
        html+="*";
    case 1:
        html+="*";
    }
document.getElementById("stars").innerHTML=html;

      </script>  
   </body>
</html>

Related Tutorials