diff --git a/index.html b/index.html index 8f536de8..8aa63d8c 100644 --- a/index.html +++ b/index.html @@ -2,14 +2,18 @@ - - + Rocks Paper Scissor +

Hello World!


+ + +
+ diff --git a/main.js b/main.js index 72f0f1a8..21320093 100644 --- a/main.js +++ b/main.js @@ -1,10 +1,17 @@ // uses strict mode so strings are not coerced, variables are not hoisted, etc... 'use strict'; +let value1 = "" +let value2 = "" + + + + // brings in the assert module for unit testing const assert = require('assert'); // brings in the readline module to access the command line const readline = require('readline'); +const { strict } = require('assert'); // use the readline module to print out to the command line const rl = readline.createInterface({ input: process.stdin, @@ -12,13 +19,73 @@ const rl = readline.createInterface({ }); // the function that will be called by the unit test below -const rockPaperScissors = (hand1, hand2) => { +const storeHand = (id, value) => { + + if (id == "first-hand") { + value1 = value + } else if (id == "second-hand") { + value2 = value + } +} + +const displayResults = () => { + + if (value1 && Value2){ + document.getElementById("display-element").innerHTML = rockPaperScissors(value1, value2) + } else { + return document.getElementById("display-element").innerHTML = "Please Enter a Hand" + } +} + + + +const rockPaperScissors = (firstHand, secondHand) => { + + let hand1 = firstHand.toLowerCase().trim() + let hand2 = secondHand.toLowerCase().trim() + + // Should come back a tie!! // + if (hand1 === 'rock' && hand2 === 'rock'){ + return "It's a tie!" + } + if (hand1 === 'paper' && hand2 === 'paper'){ + return "It's a tie!" + } + if (hand1 === 'scissors' && hand2 === 'scissors'){ + return "It's a tie!" + } + + // Detects which hand wins // + 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 === 'scissors' && hand2 === 'paper'){ + return "Hand one wins!" + } + if (hand1 === 'rock' && hand2 === 'scissors'){ + return "Hand one wins!" + } + // Write code here + // Use the unit test to see what is expected } - +const trimAndCase = () => { + str.toLowerCase() + str.trim() +} // 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 @@ -31,6 +98,14 @@ function getPrompt() { }); } + + + + + + + + // Unit Tests // You use them run the command: npm test main.js // to close them ctrl + C