calculate based on number choice with array indexOf - Javascript Array

Javascript examples for Array:indexOf

Description

calculate based on number choice with array indexOf

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//w  w w.  jav a  2  s . co  m
var value = "8";
    if (["1","2","3","4","5"].indexOf(value) != -1) {
       console.log('here 1');
    }
    else if (["8","9","12"].indexOf(value) != -1) {
       console.log('here 2');
    }
    else if (value == "11")  {
      console.log('here 3');
   }
    }

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

Related Tutorials