From bcca0b36edb69709a2e165ccbb33debf37516a31 Mon Sep 17 00:00:00 2001 From: uhuru3 Date: Sun, 28 Oct 2018 14:14:39 -0700 Subject: [PATCH 1/2] New Brach Changes --- 01week/rockPaperScissors.js | 1 + 1 file changed, 1 insertion(+) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 16f58790a..a4a4bd18c 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -7,6 +7,7 @@ const rl = readline.createInterface({ output: process.stdout }); +// nothing function rockPaperScissors(hand1, hand2) { From 310f161dbbebb41da4cdd899219a9525fa97f511 Mon Sep 17 00:00:00 2001 From: uhuru3 Date: Sun, 28 Oct 2018 14:17:27 -0700 Subject: [PATCH 2/2] Fixed copy --- 01week/rockPaperScissors.js | 101 +++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index a4a4bd18c..53e384d85 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -7,13 +7,110 @@ const rl = readline.createInterface({ output: process.stdout }); -// nothing + +const user1 = 'player1'; +const user2 = 'player2'; + function rockPaperScissors(hand1, hand2) { // Write code here -} + +// 1. User1 input of rock, paper, or scissors. + const choice = ['rock', 'paper' , 'scissors']=>{ +if (! choice) { + // User choice was undefined + return ("

Player 1, type in a correct input (rock, paper, or scissors).

"); +} else { + // Display user choice + return("

Player 1:" + " " + choice + "

") + } +}; + +// 2. User2 input of rock, paper, or scissors. +const choice = ['rock', 'paper' , 'scissors']=>{ + if (! choice) { + // User choice was undefined + return ("

Player 2, type in a correct input (rock, paper, or scissors).

"); + } else { + // Display user choice + return("

Player 2:" + " " + choice + "

") + } + }; + +// 3. Compare User1 input to User2 input. +const checkUserInput=()=>{ + +}; + +// 4. If User1 input is 'rock' and User2 input is 'scissor', User1 wins. +if (user1 === "rock") { + if (user2 === "scissors") { + // rock wins + return "You win!"; + } else { + // paper wins + return "You lose! Try again."; + } +}; + +// 5. If User1 input is 'rock' and User2 input is 'paper', User2 wins. +if (user1 === "rock") { + if (user2 === "paper") { + // paper wins + return "You win!"; + }; + +// 6. If User1 input is 'rock' and User2 input is 'rock', it's a tie. +const compare = (hand1,hand2)=> { + if (hand1 === hand2) { + return "It's a tie!"; + } + +// 7. If User1 input is 'paper' and User2 input is 'rock', User1 wins. +if (user1 === "paper") { + if (user2 === "rock") { + // paper wins + return "You win!"; + } + +// 8. If User1 input is 'paper' and User2 input is 'scissors', User2 wins. +if (user1 === "rock") { + if (user2 === "scissors") { + // scissors wins + return "You win!"; + } + +// 9. If User1 input is 'paper' and User2 input is 'paper', it's a tie. +const compare = (hand1,hand2)=> { + if (hand1 === hand2) { + return "It's a tie!"; + } + +// 10. If User1 input is 'scissors' and User2 input is 'paper', User1 wins. +if (user1 === "scissors") { + if (user2 === "paper") { + // scissors wins + return "You win!"; + } + +// 11. If User1 input is 'scissors' and User2 input is 'rock', User2 wins. +if (user1 === "scissors") { + if (user2 === "rock") { + // rock wins + return "You win!"; + } + +// 12. If User1 input is 'scissors' and User2 input is 'scissors', it's a tie. +const compare = (hand1,hand2)=> { + if (hand1 === hand2) { + return "It's a tie!"; + } + +}; + + function getPrompt() { rl.question('hand1: ', (answer1) => {