Skip to content
Open
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
29 changes: 27 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,42 @@ const rl = readline.createInterface({
const rockPaperScissors = (hand1, hand2) => {

// Write code here
// Use the unit test to see what is expected
hand1 = hand1.trim().toLowerCase();
hand2 = hand2.trim().toLowerCase();

// Write code here
if (hand1 === hand2){
return "It's a tie!";
} else if (hand1 === 'rock'){
if (hand2 === 'paper'){
return "Hand two wins!";
} else{
return "Hand one wins!";
}
} else if (hand1 === 'paper'){
if (hand2 === 'rock'){
return "Hand one wins!";
} else {
return "Hand two wins!";
}
} else{
if(hand2 === 'rock'){
return "Hand two wins!";
} else{
return "Hand one wins!";
}
}
// Use the unit test to see what is expected
}


// 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
function getPrompt() {
rl.question('hand1: ', (answer1) => {
rl.question('hand2: ', (answer2) => {
console.log( rockPaperScissors(answer1, answer2) );
console.log(rockPaperScissors(answer1, answer2));
getPrompt();
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"eslint": "^3.19.0",
"functional-javascript-workshop": "^1.0.6",
"htmllint-cli": "github:kevincolten/htmllint-cli",
"http-server": "^0.11.1",
"http-server": "^0.12.3",
"javascripting": "^2.6.1",
"jsdom": "^11.6.2",
"mocha": "^5.0.0",
Expand Down