determining var type from prompt command and if else statement - Javascript Statement

Javascript examples for Statement:if

Description

determining var type from prompt command and if else statement

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(){/*from w  w  w  .j ava2s.  c  o m*/
var guess = parseInt(prompt('What is 2 + 2?'), 10);
switch (guess) {
    case 4:
        console.log('Well done!');
        break;
    case 3:
    case 5:
        console.log('good!');
        break;
    default:
        console.log('hi.');
        break;
}
    }

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

Related Tutorials