Skip to content

Instantly share code, notes, and snippets.

@aksnell
Created June 17, 2020 13:29
Show Gist options
  • Save aksnell/d4a48876be4b648c172a54445161a051 to your computer and use it in GitHub Desktop.
Save aksnell/d4a48876be4b648c172a54445161a051 to your computer and use it in GitHub Desktop.
const rps = (firstThrow, secondThrow) => {
if (firstThrow === secondThrow) {
return 'Draw!'
}
switch (firstThrow) {
case 'rock':
return (secondThrow === 'scissors') ? 'Player 1 won!' : 'Player 2 won!'
case 'paper':
return (secondThrow === 'rock') ? 'Player 1 won!' : 'Player 2 won!'
case 'scissors':
return (secondThrow === 'paper') ? 'Player 1 won!' : 'Player 2 won!'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment