diff --git a/main.js b/main.js index e98b0914..f94e0e46 100644 --- a/main.js +++ b/main.js @@ -13,6 +13,34 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { + hand1 = hand1.trim().toLowerCase() + +hand2 = hand2.trim().toLowerCase() + + + if(hand1 === hand2) { + return "It's a tie!" + } + + if(hand1 === "rock" && hand2 === "paper"){ + return "Hand two wins!" + } + + if(hand1 === "rock" && hand2 === "scissors"){ + return "Hand one wins!" + } + + if(hand1 === "scissors" && hand2 === "rock"){ + return "Hand two wins!" + } + + if(hand1 === "paper" && hand2 === "rock"){ + return "Hand one wins!" + } + + if(hand1 === "paper" && hand2 === "scissors"){ + return "Hand two wins!" + } // Write code here // Use the unit test to see what is expected