diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 72f0f1a89..6c30cd43c 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -13,10 +13,35 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { - + hand1 = hand1.toLowerCase() + hand2 = hand2.toLowerCase() + hand1 = hand1.trim() + hand2 = hand2.trim() + console.log("Checking the hand", hand1) // Write code here // Use the unit test to see what is expected +if (hand1 === "rock" && hand2 === "paper"){ + return "Hand two wins!"; + } +else if (hand1 === "paper" && hand2 === "scissors"){ + return "Hand two wins!"; + } +else if (hand1 === "scissors" && hand2 === "rock"){ + return "Hand two wins!"; + } +else if (hand1 === "paper" && hand2 === "rock"){ + return "Hand one wins!"; + } +else if (hand1 === "rock" && hand2 === "scissors"){ + return "Hand one wins!"; + } +else if (hand1 === "scissors" && hand2 === "paper"){ + return "Hand one wins!"; + } +else (hand1 === hand2);{ + return "It's a tie!"; + } } // the first function called in the program to get an input from the user