From 299df07c206f25ae17285fe256c6c98504216e62 Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Tue, 14 Jul 2020 15:20:33 -0500 Subject: [PATCH 1/5] DID IT --- main.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 72f0f1a8..278396b4 100644 --- a/main.js +++ b/main.js @@ -12,12 +12,42 @@ const rl = readline.createInterface({ }); // the function that will be called by the unit test below -const rockPaperScissors = (hand1, hand2) => { + +const rockPaperScissors = (firstHand, secondHand) => { + + let hand1 = firstHand.toLowerCase().trim() + let hand2 = secondHand.toLowerCase().trim() + + // should detect a tie + + if (hand1 === 'rock' && hand2 === 'rock') { + return "It's a tie!" + } + if (hand1 === 'paper' && hand2 === 'paper') { + return "It's a tie!" + } + if (hand1 === 'scissors' && hand2 === 'scissors') { + return "It's a tie!" + } + +// should detect which hand won + + if (hand1 === 'rock' && hand2 === 'paper') { + return "Hand two wins!" + } + if (hand1 === 'paper' && hand2 === 'scissors') { + return "Hand two wins!" + } + if (hand1 === 'rock' && hand2 === 'scissors') { + return "Hand one wins!" + } + +} + // Write code here // Use the unit test to see what is expected -} // the first function called in the program to get an input from the user // to run the function use the command: node main.js From ef6fb33872da4d0c7c36f3c1200cc06d36803b35 Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Tue, 14 Jul 2020 15:33:45 -0500 Subject: [PATCH 2/5] ok ok now there are 9 options --- main.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/main.js b/main.js index 278396b4..06217b4e 100644 --- a/main.js +++ b/main.js @@ -32,17 +32,25 @@ const rockPaperScissors = (firstHand, secondHand) => { // should detect which hand won - if (hand1 === 'rock' && hand2 === 'paper') { - return "Hand two wins!" - } - if (hand1 === 'paper' && hand2 === 'scissors') { - return "Hand two wins!" - } - if (hand1 === 'rock' && hand2 === 'scissors') { - return "Hand one wins!" - } - -} + if (hand1 === 'rock' && hand2 === 'paper') { + return "Hand two wins!" + } + if (hand1 === 'paper' && hand2 === 'scissors') { + return "Hand two wins!" + } + if (hand1 === 'rock' && hand2 === 'scissors') { + return "Hand one wins!" + } + if (hand1 === 'paper' && hand2 === 'rock') { + return "Hand one wins!" + } + if (hand1 === 'scissors' && hand2 === 'rock') { + return "Hand two wins!" + } + if (hand1 === 'scissors' && hand2 === 'paper') { + return "Hand one wins!" + } + } // Write code here From dfb2a250b09b859ed0ee41d0b5e29c81f4883abb Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Tue, 14 Jul 2020 16:56:51 -0500 Subject: [PATCH 3/5] working it --- index.html | 8 +++++--- main.js | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 8f536de8..a221b113 100644 --- a/index.html +++ b/index.html @@ -3,13 +3,15 @@