Skip to content

Instantly share code, notes, and snippets.

@ericdodds
Created September 8, 2014 00:22
Show Gist options
  • Save ericdodds/129b6691930d7691cd51 to your computer and use it in GitHub Desktop.
Save ericdodds/129b6691930d7691cd51 to your computer and use it in GitHub Desktop.
var userChoice = prompt("Do you choose rock, paper, scissors or rope?");
var computerChoice = Math.random();
if (computerChoice <= 0.25)
{
computerChoice = "rock";
}
else if (0.26 <= computerChoice <= 0.50)
{
computerChoice = "paper";
}
else if (0.51 <= computerChoice <= 0.75)
{
computerChoice = "scissors";
}
else
{
computerChoice = "rope";
}
console.log("Computer: " + computerChoice);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment