From 6135939fa7e8a8c74b4a05bc6baf429c7a283423 Mon Sep 17 00:00:00 2001 From: Jacoblynch99 Date: Tue, 14 Jul 2020 15:37:20 -0500 Subject: [PATCH 1/3] initial commit --- main.js | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 72f0f1a8..a6d98e83 100644 --- a/main.js +++ b/main.js @@ -12,11 +12,46 @@ const rl = readline.createInterface({ }); // the function that will be called by the unit test below -const rockPaperScissors = (hand1, hand2) => { +const rockPaperScissors = (firstHand, secondHand) => { - // Write code here - // Use the unit test to see what is expected + let hand1 = firstHand.toLowerCase().trim() + let hand2 = secondHand.toLowerCase().trim() + + switch (hand1) { + + case 'rock': + switch (hand2) { + case 'rock': + return "It's a tie!" + case 'paper': + return "Hand two wins!" + case 'scissors': + return "Hand one wins!" + } + break; + case 'paper': + switch (hand2) { + case 'rock': + return "Hand one wins!" + case 'paper': + return "It's a tie!" + case 'scissors': + return "Hand two wins!" + } + break; + + case 'scissors': + switch (hand2) { + case 'rock': + return "Hand two wins!" + case 'paper': + return "Hand one wins!" + case 'scissors': + return "It's a tie!" + } + break; + } } // the first function called in the program to get an input from the user From d216fee572c4f243d7c72254d54c16475d22311d Mon Sep 17 00:00:00 2001 From: Jacoblynch99 Date: Tue, 14 Jul 2020 16:58:18 -0500 Subject: [PATCH 2/3] commit this shit --- index.html | 13 ++++++++----- main.js | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 8f536de8..5611b94a 100644 --- a/index.html +++ b/index.html @@ -3,13 +3,16 @@ - +

Hello World!

-
-
- -
+ + diff --git a/main.js b/main.js index a6d98e83..969d3d6b 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,9 @@ // uses strict mode so strings are not coerced, variables are not hoisted, etc... 'use strict'; +// let valueOne = "" +// let valueTwo = "" + // brings in the assert module for unit testing const assert = require('assert'); // brings in the readline module to access the command line @@ -12,6 +15,24 @@ const rl = readline.createInterface({ }); // the function that will be called by the unit test below + +// const displayResults = () => { + +// if (valueOne && valueTwo) { +// document.getElementById("RPS").innerHTML = rockPaperScissors(valueOne, valueTwo) +// } else { +// document.getElementById("RPS").innerHTML = "Please input rock, paper, or scissors." +// } +// } + +// const storeHand = (id, value) => { +// if (id == "first-hand") { +// valueOne = value +// } else if (id == "second-hand") { +// valueTwo = value +// } +// } + const rockPaperScissors = (firstHand, secondHand) => { let hand1 = firstHand.toLowerCase().trim() From dee557aaacf4e87c8ed625a31aafd7bfdb3c79fd Mon Sep 17 00:00:00 2001 From: Jacoblynch99 Date: Thu, 16 Jul 2020 11:11:18 -0500 Subject: [PATCH 3/3] update js' --- main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 969d3d6b..11c73cac 100644 --- a/main.js +++ b/main.js @@ -37,9 +37,11 @@ const rockPaperScissors = (firstHand, secondHand) => { let hand1 = firstHand.toLowerCase().trim() let hand2 = secondHand.toLowerCase().trim() + + switch (hand1) { - + case 'rock': switch (hand2) { case 'rock': @@ -72,6 +74,7 @@ const rockPaperScissors = (firstHand, secondHand) => { return "It's a tie!" } break; + } }