diff --git a/main.js b/main.js index e98b0914..a36f16fa 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -// uses strict mode so strings are not coerced, variables are not hoisted, etc... +;// uses strict mode so strings are not coerced, variables are not hoisted, etc... 'use strict'; // brings in the assert module for unit testing @@ -9,10 +9,27 @@ const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout -}); +}); // the function that will be called by the unit test below -const rockPaperScissors = (hand1, hand2) => { +const rockPaperScissors = (h1, h2) => { + const hand1 = h1.toLowerCase().trim() + const hand2 = h2.toLowerCase().trim() + if (hand1 == hand2) { + 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 == "rock" && hand2 == "scissors"){ + return "Hand one wins!" + } + // Write code here // Use the unit test to see what is expected @@ -25,7 +42,7 @@ const rockPaperScissors = (hand1, hand2) => { function getPrompt() { rl.question('hand1: ', (answer1) => { rl.question('hand2: ', (answer2) => { - console.log( rockPaperScissors(answer1, answer2) ); + console.log(rockPaperScissors(answer1, answer2)); getPrompt(); }); }); diff --git a/package.json b/package.json index 09c5e8f1..3c9aae17 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,14 @@ }, "homepage": "https://github.com/AustinCodingAcademy/JS211_RockPaperScissorsProject#readme", "dependencies": { - "eslint": "^3.19.0", - "functional-javascript-workshop": "^1.0.6", + "eslint": "^8.23.0", + "functional-javascript-workshop": "^0.0.23", "htmllint-cli": "github:kevincolten/htmllint-cli", - "http-server": "^0.11.1", - "javascripting": "^2.6.1", - "jsdom": "^11.6.2", - "mocha": "^5.0.0", + "http-server": "^14.1.1", + "javascripting": "^2.4.0", + "jsdom": "^20.0.0", + "mocha": "^10.0.0", "postcss-html": "^0.34.0", - "stylelint": "^7.13.0" + "stylelint": "^14.11.0" } }