diff --git a/index.html b/index.html index 8f536de8..5611b94a 100644 --- a/index.html +++ b/index.html @@ -3,13 +3,16 @@ - +

Hello World!

-
-
- -
+ + diff --git a/main.js b/main.js index 72f0f1a8..11c73cac 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,9 @@ // uses strict mode so strings are not coerced, variables are not hoisted, etc... 'use strict'; +// let valueOne = "" +// let valueTwo = "" + // brings in the assert module for unit testing const assert = require('assert'); // brings in the readline module to access the command line @@ -12,11 +15,67 @@ 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 +// const displayResults = () => { + +// if (valueOne && valueTwo) { +// document.getElementById("RPS").innerHTML = rockPaperScissors(valueOne, valueTwo) +// } else { +// document.getElementById("RPS").innerHTML = "Please input rock, paper, or scissors." +// } +// } + +// const storeHand = (id, value) => { +// if (id == "first-hand") { +// valueOne = value +// } else if (id == "second-hand") { +// valueTwo = value +// } +// } + +const rockPaperScissors = (firstHand, secondHand) => { + + let hand1 = firstHand.toLowerCase().trim() + let hand2 = secondHand.toLowerCase().trim() + + + + switch (hand1) { + + case 'rock': + switch (hand2) { + case 'rock': + return "It's a tie!" + case 'paper': + return "Hand two wins!" + case 'scissors': + return "Hand one wins!" + } + break; + + case 'paper': + switch (hand2) { + case 'rock': + return "Hand one wins!" + case 'paper': + return "It's a tie!" + case 'scissors': + return "Hand two wins!" + } + break; + + case 'scissors': + switch (hand2) { + case 'rock': + return "Hand two wins!" + case 'paper': + return "Hand one wins!" + case 'scissors': + return "It's a tie!" + } + break; + } } // the first function called in the program to get an input from the user