Created
June 3, 2020 01:33
-
-
Save KamariRoss/6b17e652e662cab16c9a44d5568ff6a6 to your computer and use it in GitHub Desktop.
Rock Paper Scissors! Kata
This file contains 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
https://www.codewars.com/kata/5672a98bdbdd995fad00000f/solutions/javascript | |
Rock Paper Scissors | |
Let's play! You have to return which player won! In case of a draw return Draw!. | |
Examples: | |
rps('scissors','paper') // Player 1 won! | |
rps('scissors','rock') // Player 2 won! | |
rps('paper','paper') // Draw! | |
rockpaperscissors | |
const rps = (p1, p2) => { | |
if (p1 == p2) | |
{return "Draw!";} | |
else if ((p1 == "scissors" && p2 == "paper") || | |
(p1 == "paper" && p2 == "rock") || | |
(p1 == "rock" && p2 == "scissors") ) | |
{return "Player 1 won!";} | |
else | |
{ return "Player 2 won!";} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment