diff --git a/index.html b/index.html index 8f536de8..38d586bf 100644 --- a/index.html +++ b/index.html @@ -6,10 +6,6 @@ -

Hello World!

-
-
- -
+ diff --git a/main.js b/main.js index e98b0914..2f0de9da 100644 --- a/main.js +++ b/main.js @@ -13,10 +13,16 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { - - // Write code here - // Use the unit test to see what is expected - + let words = ['rock', 'paper', 'scissors'] + let User1 = words.indexOf(hand1.trim().toLowerCase()) + let User2 = words.indexOf(hand2.trim().toLowerCase()) +if (User1 === User2) {return "It's a tie!"} +else if (User1 === 0 & User2 === 2) {return "Hand one wins!"} +else if (User1 === 1 & User2 === 0) {return "Hand one wins!"} +else if (User1 === 2 & User2 === 1) {return "Hand one wins!"} +else if (User2 === 0 & User1 === 2) {return "Hand two wins!"} +else if (User2 === 1 & User1 === 0) {return "Hand two wins!"} +else if (User2 === 2 & User1 === 1) {return "Hand two wins!"} } // the first function called in the program to get an input from the user @@ -60,3 +66,24 @@ if (typeof describe === 'function') { getPrompt(); } + + + +// let PlayGame = (Player1,PLayer2) => { +// let words = ['rock', 'paper', 'scissors'] +// let P1 = words.indexOf(Player1.toLowerCase()) +// let P2 = words.indexOf(PLayer2.toLowerCase()) +// console.log('User1:' + words[P1] + ' User2:' + words[P2]) + // if (P1 === P2) {console.log('Tie!')} + // else if (P1 === 0 & P2 === 2) {console.log('User1 Wins')} + // else if (P1 === 1 & P2 === 0) {console.log('User1 Wins')} + // else if (P1 === 2 & P2 === 1) {console.log('User1 Wins')} + // else if (P2 === 0 & P1 === 2) {console.log('User2 Wins')} + // else if (P2 === 1 & P1 === 0) {console.log('User2 Wins')} + // else if (P2 === 2 & P1 === 1) {console.log('User2 Wins')} +// } + +// PlayGame('rock','rock') +// PlayGame('rock','scissors') + +// PlayGame('paper','scissors') \ No newline at end of file