Created
July 31, 2016 17:21
-
-
Save anonymous/c16e01ad8f7b21ebfb3ed8fb7238f69f to your computer and use it in GitHub Desktop.
https://repl.it/CXnp/45 created by sethopia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Thoughtful Thursdays - RPS | |
*/ | |
function rockPaperScissors(hand1, hand2) { | |
// hand1 equals hand2, return 'tie' | |
if (hand1 === hand2) { | |
return 'TIE'; | |
} | |
if (hand1 === 'rock' && hand2 === 'paper' || | |
hand1 === 'paper' && hand2 === 'scissors' || | |
hand1 === 'scissors' && hand2 === 'rock') { | |
return 'player2'; | |
} | |
return 'player1'; | |
} | |
console.log(rockPaperScissors('rock', 'rock')); | |
console.log(rockPaperScissors('paper', 'rock')); | |
console.log(rockPaperScissors('scissors', 'rock')); | |
console.log(rockPaperScissors('scissors', 'paper')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Native Browser JavaScript | |
>>> TIE | |
player1 | |
player2 | |
player1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment