Check string value for three options with if statement - Javascript Statement

Javascript examples for Statement:if

Description

Check string value for three options with if 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(){//w  w w. j a  v a2 s.  co  m
var userChoice = 'rock';
if ((userChoice != "rock") && (userChoice != "paper") && (userChoice != "scissors")) {
    console.log("inappropriate choice");
} else {
    console.log("appropriate choice!");
}
    }

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

Related Tutorials