ForeverDev

Untitled

Oct 4th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var moves = {1 : "rock", 2 : "paper", 3 : "scissors"}
  2.  
  3. while (true) {
  4.     var enemyDecision = moves[Math.ceil(Math.random() * 3)]
  5.     var myDecision = prompt("Rock, paper, or scissors?").toLowerCase()
  6.     var result = (
  7.         myDecision == enemyDecision && "Tie!" ||
  8.         (
  9.             myDecision == "rock" && enemyDecision == "paper" ||
  10.             myDecision == "paper" && enemyDecision == "scissors" ||
  11.             myDecision == "scissors" && enemyDecision == "rock"
  12.         ) && "You lose!" ||
  13.         "You win!"
  14.     )
  15.     console.log(result + " You chose " + myDecision + " and your opponent chose " + enemyDecision)
  16. }
Advertisement
Add Comment
Please, Sign In to add comment