Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. //USER CLICKS Scissors
  2. //------------------------------------------------------------
  3. $(document).ready(function() {
  4. $("#icon_scissors").click(function(){
  5. // Do your stuff here
  6. var userChoice = "Scissors";
  7. //Deciding computer choice
  8. var computerChoice = Math.random();
  9. if (computerChoice <0.34){
  10. computerChoice = "Rock";
  11. }else if(computerChoice <=0.67){
  12. computerChoice = "Paper";
  13. }
  14. else{
  15. computerChoice = "Scissors";
  16. }
  17. //Deciding winner
  18. switch(computerChoice) {
  19. case "Scissors":
  20. outcome= "Its a tie!";
  21. break;
  22. case "Rock":
  23. outcome= "You lost!";
  24. break;
  25. case "Paper":
  26. outcome="You won!";
  27. break;
  28. default:
  29. outcome = "Error - WinnerSelectionError";
  30. }//End of switch
  31.  
  32.  
  33.  
  34.  
  35. //Output to user
  36. console.log(outcome);
  37. $("#computerChoiceOutput").text(computerChoice)
  38. $("#outcomeOutput").text(outcome);
  39.  
  40.  
  41.  
  42. });
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement