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 @@ -

Hello World!


-
- +
+ + +
+ diff --git a/main.js b/main.js index 06217b4e..63d530f3 100644 --- a/main.js +++ b/main.js @@ -1,18 +1,42 @@ // uses strict mode so strings are not coerced, variables are not hoisted, etc... 'use strict'; +let value1 = "" +let value2 = "" + // brings in the assert module for unit testing -const assert = require('assert'); +// const assert = require('assert'); // brings in the readline module to access the command line -const readline = require('readline'); +// const readline = require('readline'); // use the readline module to print out to the command line -const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout -}); +// const rl = readline.createInterface({ +// input: process.stdin, +// output: process.stdout +// }); // the function that will be called by the unit test below +//1 create two inputs +//2 create a function that when inputs are typed in is called and saves inputs to two different global variables +//3 create a button +//4 create a function, that when button is clicked, displays the results of RPS function +const storeHand = (id,value) => { + if (id == "first-hand") { + value1 = value + } else if (id == "second-hand") { + value2 = value + } +} + +const displayResults = () => { + if (value1 && value2){ + document.getElementById("RPS").innerHTML = rockPaperScissors(value1, value2) + } else { + return document.getElementById("RPS").innerHTML = "FAIL" + } +} + + const rockPaperScissors = (firstHand, secondHand) => { let hand1 = firstHand.toLowerCase().trim() From b78a7723934444b5809bc9285d9a6b5fa9cdeecb Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Tue, 14 Jul 2020 16:59:05 -0500 Subject: [PATCH 4/5] commented out stuff --- main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index 63d530f3..1b220094 100644 --- a/main.js +++ b/main.js @@ -5,14 +5,14 @@ let value1 = "" let value2 = "" // brings in the assert module for unit testing -// const assert = require('assert'); +const assert = require('assert'); // brings in the readline module to access the command line -// const readline = require('readline'); +const readline = require('readline'); // use the readline module to print out to the command line -// const rl = readline.createInterface({ -// input: process.stdin, -// output: process.stdout -// }); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); // the function that will be called by the unit test below From 9fab8a6a30222cb78271cf75a500e6c9e5da2e29 Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Thu, 16 Jul 2020 11:32:24 -0500 Subject: [PATCH 5/5] turnin this biotch in --- main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 1b220094..49ea3a64 100644 --- a/main.js +++ b/main.js @@ -38,7 +38,7 @@ const displayResults = () => { const rockPaperScissors = (firstHand, secondHand) => { - + console.log(firstHand) let hand1 = firstHand.toLowerCase().trim() let hand2 = secondHand.toLowerCase().trim() @@ -115,6 +115,11 @@ if (typeof describe === 'function') { assert.equal(rockPaperScissors('Paper', 'SCISSORS'), "Hand two wins!"); assert.equal(rockPaperScissors('rock ', 'sCiSsOrs'), "Hand one wins!"); }); + // + it('should test for input before moving to next turn', () => { + assert.equal(rockPaperScissors(undefined, ' paper '), "You suck"); + assert.equal(rockPaperScissors('Paper', undefined), "Don't be dumb"); + }); }); } else {