/*ROCK PAPER SCISSORS*/
/*
1 = Rock
2 = Paper
3 = Scissors
*/
var randomInt = Math.floor(Math.random() * 3) + 1;
var computerChoice = "";
if (randomInt == 1) computerChoice = "rock";
else if (randomInt == 2) computerChoice = "paper"
else if (randomInt == 3) computerChoice = "scissors";
var userChoice = "";
while(userChoice.toLowerCase() != "rock" &&
userChoice.toLowerCase() != "paper" &&
userChoice.toLowerCase() != "scissors"){
userChoice = prompt("Please enter Rock Paper or Scissors");
}
var status ="";
switch(computerChoice){
case "rock":
if (userChoice=="rock") status="drew";
else if (userChoice=="paper") status="win";
else if (userChoice=="scissors") status="lose";
break;
case "paper":
if (userChoice=="rock") status="lose";
else if (userChoice=="paper") status="drew";
else if (userChoice=="scissors") status="win";
break;
case "scissors":
if (userChoice=="rock") status = "win";
else if (userChoice=="paper") status="lose";
else if (userChoice=="scissors") status="drew";
break;
}
alert("You: " + userChoice.toLowerCase() + ". \nComputer: " + computerChoice.toLowerCase() + ".\nResult: You " + status);