curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6925e2068081f40f549ced1d.md
Given two strings, the first representing Player 1 and the second representing Player 2, determine the winner of a match of Rock, Paper, Scissors.
"Rock", "Paper", or "Scissors"."Rock" beats "Scissors"."Paper" beats "Rock"."Scissors" beats "Paper".Return:
"Player 1 wins" if Player 1 wins."Player 2 wins" if Player 2 wins."Tie" if both players choose the same option.rockPaperScissors("Rock", "Rock") should return "Tie".
assert.equal(rockPaperScissors("Rock", "Rock"), "Tie");
rockPaperScissors("Rock", "Paper") should return "Player 2 wins".
assert.equal(rockPaperScissors("Rock", "Paper"), "Player 2 wins");
rockPaperScissors("Scissors", "Paper") should return "Player 1 wins".
assert.equal(rockPaperScissors("Scissors", "Paper"), "Player 1 wins");
rockPaperScissors("Rock", "Scissors") should return "Player 1 wins".
assert.equal(rockPaperScissors("Rock", "Scissors"), "Player 1 wins");
rockPaperScissors("Scissors", "Scissors") should return "Tie".
assert.equal(rockPaperScissors("Scissors", "Scissors"), "Tie");
rockPaperScissors("Scissors", "Rock") should return "Player 2 wins".
assert.equal(rockPaperScissors("Scissors", "Rock"), "Player 2 wins");
function rockPaperScissors(player1, player2) {
return player1;
}
function rockPaperScissors(player1, player2) {
if (player1 === player2) return "Tie";
if (
(player1 === "Rock" && player2 === "Scissors") ||
(player1 === "Paper" && player2 === "Rock") ||
(player1 === "Scissors" && player2 === "Paper")
) {
return "Player 1 wins";
} else {
return "Player 2 wins";
}
}