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
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="main.js"></script>
<title>Rocks Paper Scissor</title>

</head>
<body>
<h1>Hello World!</h1>
<hr/>
<div id="display-element"></div>
<button onclick="displayDate()">Click Me</button>
<input type="text" id="first-hand" name="first-hand" value="" onkeyup="storeHand(this.id, this.value)">
<input type="text" id="second-hand" name="second-hand" value="" onkeyup="storeHand(this.id, this.value)">
<button onclick="displayResults()">Hands</button>
<hr/>
<script src="main.js"></script>
</body>
</html>
79 changes: 77 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,91 @@
// 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,
output: process.stdout
});

// 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
Expand All @@ -31,6 +98,14 @@ function getPrompt() {
});
}









// Unit Tests
// You use them run the command: npm test main.js
// to close them ctrl + C
Expand Down