Skip to content

Instantly share code, notes, and snippets.

@BrianHicks
Last active December 14, 2015 23:29
Show Gist options
  • Save BrianHicks/5165964 to your computer and use it in GitHub Desktop.
Save BrianHicks/5165964 to your computer and use it in GitHub Desktop.
function compare(choice1, choice2) {
if (choice1 == choice2) return "The result is a tie!";
if (choice1 == "rock") {
if (choice2 == "paper") {
return "paper wins";
} else { // scissors
return "rock wins";
}
// or with a ternary statement...
//return (choice2 == "paper" ? "paper" : "rock") + " wins"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment