From fb58d94ac4bbcc626e688d121acdc5b9e7afe1c0 Mon Sep 17 00:00:00 2001 From: Daryl McAvoy Date: Fri, 10 Jan 2020 18:39:57 -0600 Subject: [PATCH] complete --- main.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main.js b/main.js index 72f0f1a8..b6b888e0 100644 --- a/main.js +++ b/main.js @@ -16,7 +16,30 @@ const rockPaperScissors = (hand1, hand2) => { // Write code here // Use the unit test to see what is expected + hand1 = hand1.trim().toLowerCase(); + hand2 = hand2.trim().toLowerCase(); + + //Pass results back + let result; + + + if (hand1 === hand2){ + result = "It's a tie!"; + return result; + + + } else if ((hand1 == 'paper' && hand2 == 'rock' ) || (hand1 == 'rock' && hand2 == 'scissors') || (hand1 == 'scissors' && hand2 == 'paper' )) { + // All the conditions for Hand 1 to win. + result = "Hand one wins!"; + return result; + + + } else if ((hand2 == 'paper' && hand1 == 'rock') || (hand2 == 'rock' && hand1 == 'scissors' ) || (hand2 == 'scissors' && hand1 == 'paper')) { + // All the conditions for Hand 2 to win. + result = "Hand two wins!"; + return result; + } } // the first function called in the program to get an input from the user