From b7a849599fa2b1b24554a4db3a62431abafea198 Mon Sep 17 00:00:00 2001 From: JeffAStringer Date: Wed, 2 Dec 2020 20:25:18 -0600 Subject: [PATCH 1/2] class work week 1 --- main.js | 31 ++++++++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 72f0f1a8..25ac5757 100644 --- a/main.js +++ b/main.js @@ -13,7 +13,36 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { - + const rockPaperScissors = (hand1, hand2) => { + if(hand1===hand2){ + return "The result is a tie!"; + } + else if(hand1==="rock"){ + if(hand2==="scissors"){ + return "rock wins" + } + else if(hand2==="paper"){ + return "paper wins"; + } + } + else if(hand1==="paper"){ + if(hand2==="scissors"){ + return "scissors win" + } + else if(hand2==="rock"){ + return "paper wins"; + } + } + else if(hand1==="scissors"){ + if(hand2==="paper"){ + return "scissors win" + } + else if(hand2==="rock"){ + return "rock wins"; + } + } + +} // Write code here // Use the unit test to see what is expected diff --git a/package.json b/package.json index 09c5e8f1..eefd2ea0 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "eslint": "^3.19.0", "functional-javascript-workshop": "^1.0.6", "htmllint-cli": "github:kevincolten/htmllint-cli", - "http-server": "^0.11.1", + "http-server": "^0.12.3", "javascripting": "^2.6.1", "jsdom": "^11.6.2", "mocha": "^5.0.0", From 44c98b44e7477e90cfc960ff0dd540f27e82fb84 Mon Sep 17 00:00:00 2001 From: JeffAStringer Date: Wed, 2 Dec 2020 20:52:50 -0600 Subject: [PATCH 2/2] classwork changes --- main.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/main.js b/main.js index 25ac5757..16ee97b5 100644 --- a/main.js +++ b/main.js @@ -13,32 +13,34 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { - const rockPaperScissors = (hand1, hand2) => { - if(hand1===hand2){ - return "The result is a tie!"; + hand1 = hand1.trim().toLowerCase(); + hand2 = hand2.trim().toLowerCase(); + + if(hand1===hand2){ + return "It's a tie!"; } else if(hand1==="rock"){ if(hand2==="scissors"){ - return "rock wins" + return "Hand one wins!" } else if(hand2==="paper"){ - return "paper wins"; + return "Hand two wins!"; } } else if(hand1==="paper"){ if(hand2==="scissors"){ - return "scissors win" + return "Hand two wins!" } else if(hand2==="rock"){ - return "paper wins"; + return "Hand one wins!"; } } else if(hand1==="scissors"){ if(hand2==="paper"){ - return "scissors win" + return "Hand one wins!" } else if(hand2==="rock"){ - return "rock wins"; + return "Hand two wins"; } } @@ -46,7 +48,7 @@ const rockPaperScissors = (hand1, hand2) => { // 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