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
6 changes: 1 addition & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<script src="main.js"></script>
</head>
<body>
<h1>Hello World!</h1>
<hr/>
<div id="display-element"></div>
<button onclick="displayDate()">Click Me</button>
<hr/>

</body>
</html>
35 changes: 31 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ const rl = readline.createInterface({

// the function that will be called by the unit test below
const rockPaperScissors = (hand1, hand2) => {

// Write code here
// Use the unit test to see what is expected

let words = ['rock', 'paper', 'scissors']
let User1 = words.indexOf(hand1.trim().toLowerCase())
let User2 = words.indexOf(hand2.trim().toLowerCase())
if (User1 === User2) {return "It's a tie!"}
else if (User1 === 0 & User2 === 2) {return "Hand one wins!"}
else if (User1 === 1 & User2 === 0) {return "Hand one wins!"}
else if (User1 === 2 & User2 === 1) {return "Hand one wins!"}
else if (User2 === 0 & User1 === 2) {return "Hand two wins!"}
else if (User2 === 1 & User1 === 0) {return "Hand two wins!"}
else if (User2 === 2 & User1 === 1) {return "Hand two wins!"}
}

// the first function called in the program to get an input from the user
Expand Down Expand Up @@ -60,3 +66,24 @@ if (typeof describe === 'function') {
getPrompt();

}



// let PlayGame = (Player1,PLayer2) => {
// let words = ['rock', 'paper', 'scissors']
// let P1 = words.indexOf(Player1.toLowerCase())
// let P2 = words.indexOf(PLayer2.toLowerCase())
// console.log('User1:' + words[P1] + ' User2:' + words[P2])
// if (P1 === P2) {console.log('Tie!')}
// else if (P1 === 0 & P2 === 2) {console.log('User1 Wins')}
// else if (P1 === 1 & P2 === 0) {console.log('User1 Wins')}
// else if (P1 === 2 & P2 === 1) {console.log('User1 Wins')}
// else if (P2 === 0 & P1 === 2) {console.log('User2 Wins')}
// else if (P2 === 1 & P1 === 0) {console.log('User2 Wins')}
// else if (P2 === 2 & P1 === 1) {console.log('User2 Wins')}
// }

// PlayGame('rock','rock')
// PlayGame('rock','scissors')

// PlayGame('paper','scissors')