Techmo

JSRPS

Dec 25th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var wantedturns=prompt("Enter the number of rounds you would like to play");
  2. var score = 0;
  3. var round = 0;
  4. var turns = 0;
  5. while(turns < wantedturns)
  6. {
  7. turns++;
  8. var wep = prompt("Enter rock, paper, or scissors");
  9. var r = Math.floor((Math.random()*3)+1);
  10.  
  11.  
  12. if (r == 1)
  13. {
  14. var cwep = "rock";
  15. }
  16. if (r == 2)
  17. {
  18. var cwep = "paper";    
  19. }
  20. if (r == 3)
  21. {
  22. var cwep = "scissors";    
  23. }
  24.  
  25.  
  26. if(cwep == "scissors" && wep == "rock" && cwep != wep)
  27. {
  28. alert("You win | You: "+ wep +" | Computer: " + cwep)
  29. }
  30. if(cwep == "rock" && wep == "paper" && cwep != wep)
  31. {
  32. alert("You win | You: "+ wep +" | Computer: " + cwep)
  33. }
  34. if(cwep == "paper" && wep == "scissors" && cwep != wep)
  35. {
  36. alert("You win | You: "+ wep +" | Computer: " + cwep)
  37. }
  38.  
  39. if(cwep == "scissors" && wep == "paper" && cwep != wep)
  40. {
  41. alert("Computer wins | You: "+ wep +" | Computer: " + cwep)
  42. }if(cwep == "rock" && wep == "scissors" && cwep != wep)
  43. {
  44. alert("Computer wins | You: "+ wep +" | Computer: " + cwep)
  45. }if(cwep == "paper" && wep == "rock" && cwep != wep)
  46. {
  47. alert("Computer wins | You: "+ wep +" | Computer: " + cwep)
  48. }
  49.  
  50. if(cwep == wep)
  51. {
  52. alert("It's a tie | You: "+ wep +" | Computer: " + cwep)
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment