From 31df64e90951b64253b17ae736ad6b8dd65a83e7 Mon Sep 17 00:00:00 2001 From: Lance Hammond Jr Date: Tue, 31 Mar 2020 15:53:32 -0500 Subject: [PATCH 1/6] rockPaperScissors2 --- 01week/rockPaperScissors.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 72f0f1a89..eef831196 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -13,12 +13,29 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { - + hand1 = hand1.toLowerCase() + hand2 = hand2.toLowerCase() + console.log(hand1) // Write code here // Use the unit test to see what is expected + if (hand1 === hand2){ + return "It's a tie!"; + } + + else if (hand1 === "rock" && hand2 === "paper"){ + if (hand1 === "paper" && hand2 === "scissors"); + else (hand1 === "scissors" && hand2 === "rock"); + return "Hand two wins!"; + } + else if (hand1 === "paper" && hand2 === "rock"){ + if (hand1 === "rock" && hand2 === "scissors"); + else (hand1 === "scissors" && hand2 === "paper"); + return "Hand one wins!"; + }; } + // the first function called in the program to get an input from the user // to run the function use the command: node main.js // to close it ctrl + C From 3bf49ce7165cfcf52a1fd42513a372a52b6cef4d Mon Sep 17 00:00:00 2001 From: Lance Hammond Jr Date: Tue, 31 Mar 2020 20:24:14 -0500 Subject: [PATCH 2/6] rockPaperScissors2 --- 01week/rockPaperScissors.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index eef831196..1a86ef0fd 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -15,6 +15,8 @@ const rl = readline.createInterface({ const rockPaperScissors = (hand1, hand2) => { hand1 = hand1.toLowerCase() hand2 = hand2.toLowerCase() + hand1 = hand1.trim() + hand2 = hand2.trim() console.log(hand1) // Write code here // Use the unit test to see what is expected From 538a31a5ab5d50d628d5d090558c5db2070e71b3 Mon Sep 17 00:00:00 2001 From: Lance Hammond Jr Date: Thu, 2 Apr 2020 10:06:44 -0500 Subject: [PATCH 3/6] rockPaperScissors2 --- 01week/rockPaperScissors.js | 39 +++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 1a86ef0fd..ec82ec14e 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -17,25 +17,34 @@ const rockPaperScissors = (hand1, hand2) => { hand2 = hand2.toLowerCase() hand1 = hand1.trim() hand2 = hand2.trim() - console.log(hand1) + console.log("Checking the hand", hand1) // Write code here // Use the unit test to see what is expected - if (hand1 === hand2){ - return "It's a tie!"; - } - else if (hand1 === "rock" && hand2 === "paper"){ - if (hand1 === "paper" && hand2 === "scissors"); - else (hand1 === "scissors" && hand2 === "rock"); - return "Hand two wins!"; - } + if (hand1 === hand2){ + if (hand1 === "rock" && hand2 === "paper") + return "Hand two wins!"; + + else if (hand1 === "paper" && hand2 === "scissors") + return "Hand two wins!"; + + else if (hand1 === "scissors" && hand2 === "rock") + return "Hand two wins!" + + else if (hand1 === "paper" && hand2 === "rock") + return "Hand one wins!"; + + else if (hand1 === "rock" && hand2 === "scissors") + return "Hand one wins!"; + + else if (hand1 === "scissors" && hand2 === "paper") + return "Hand one wins!"; + + else + return "It's a tie!"; + + } - else if (hand1 === "paper" && hand2 === "rock"){ - if (hand1 === "rock" && hand2 === "scissors"); - else (hand1 === "scissors" && hand2 === "paper"); - return "Hand one wins!"; - }; -} // the first function called in the program to get an input from the user From c7c48b005d57942d586d11a74c440bcf5083e218 Mon Sep 17 00:00:00 2001 From: Lance Hammond Jr Date: Thu, 2 Apr 2020 19:18:07 -0500 Subject: [PATCH 4/6] rockPaperScissors2 --- 01week/rockPaperScissors.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index ec82ec14e..69fe1c6fa 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -22,29 +22,29 @@ const rockPaperScissors = (hand1, hand2) => { // Use the unit test to see what is expected if (hand1 === hand2){ - if (hand1 === "rock" && hand2 === "paper") + if (hand1 === "rock" && hand2 === "paper"){ return "Hand two wins!"; - - else if (hand1 === "paper" && hand2 === "scissors") + } + if (hand1 === "paper" && hand2 === "scissors"){ return "Hand two wins!"; - - else if (hand1 === "scissors" && hand2 === "rock") - return "Hand two wins!" - - else if (hand1 === "paper" && hand2 === "rock") + } + if (hand1 === "scissors" && hand2 === "rock"){ + return "Hand two wins!"; + } + if (hand1 === "paper" && hand2 === "rock"){ return "Hand one wins!"; - - else if (hand1 === "rock" && hand2 === "scissors") + } + if (hand1 === "rock" && hand2 === "scissors"){ return "Hand one wins!"; - - else if (hand1 === "scissors" && hand2 === "paper") + } + if (hand1 === "scissors" && hand2 === "paper"){ return "Hand one wins!"; - - else + } + else{ return "It's a tie!"; } - + } // the first function called in the program to get an input from the user From 1532a01f54bdfa30a27ea9d3251f123440211084 Mon Sep 17 00:00:00 2001 From: Lance Hammond Jr Date: Thu, 2 Apr 2020 20:15:49 -0500 Subject: [PATCH 5/6] rockPaperScissors2 --- 01week/rockPaperScissors.js | 45 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 69fe1c6fa..6c30cd43c 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -21,31 +21,28 @@ const rockPaperScissors = (hand1, hand2) => { // Write code here // Use the unit test to see what is expected - if (hand1 === hand2){ - if (hand1 === "rock" && hand2 === "paper"){ - return "Hand two wins!"; - } - if (hand1 === "paper" && hand2 === "scissors"){ - return "Hand two wins!"; - } - if (hand1 === "scissors" && hand2 === "rock"){ - return "Hand two wins!"; - } - if (hand1 === "paper" && hand2 === "rock"){ - return "Hand one wins!"; - } - if (hand1 === "rock" && hand2 === "scissors"){ - return "Hand one wins!"; - } - if (hand1 === "scissors" && hand2 === "paper"){ - return "Hand one wins!"; - } - else{ - return "It's a tie!"; - - } +if (hand1 === "rock" && hand2 === "paper"){ + return "Hand two wins!"; } - +else if (hand1 === "paper" && hand2 === "scissors"){ + return "Hand two wins!"; + } +else if (hand1 === "scissors" && hand2 === "rock"){ + return "Hand two wins!"; + } +else if (hand1 === "paper" && hand2 === "rock"){ + return "Hand one wins!"; + } +else if (hand1 === "rock" && hand2 === "scissors"){ + return "Hand one wins!"; + } +else if (hand1 === "scissors" && hand2 === "paper"){ + return "Hand one wins!"; + } +else (hand1 === hand2);{ + return "It's a tie!"; + } +} // 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 782b8064aa2c20044514c60dfc9507ce1f2c4ad6 Mon Sep 17 00:00:00 2001 From: Lance Hammond Jr Date: Tue, 14 Apr 2020 11:55:01 -0500 Subject: [PATCH 6/6] pigLatin --- 02week/pigLatin.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 7f2b58a8a..efe2b89fc 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -9,12 +9,19 @@ const rl = readline.createInterface({ const pigLatin = (word) => { - + word = word.toLowerCase(); + word = word.trim(); + const vowels = word.match(/[aeiou]/); + const firstPosition = word.indexOf(vowels); // Your code here - + if (firstPosition > 0) { + return word.slice(firstPosition) + word.slice(0, firstPosition) + "ay"; + } + return word + "yay"; } + const getPrompt = () => { rl.question('word ', (answer) => { console.log( pigLatin(answer) );