Skip to content
Open

Main #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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();
});
});
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}