Skip to content
Open
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
100 changes: 99 additions & 1 deletion 01week/rockPaperScissors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,109 @@ const rl = readline.createInterface({
});


const user1 = 'player1';
const user2 = 'player2';


function rockPaperScissors(hand1, hand2) {
Copy link

@ericbarrs ericbarrs Oct 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameters that are being used is hand1 and hand2. The function is also not closed.


// Write code here

}

// 1. User1 input of rock, paper, or scissors.
const choice = ['rock', 'paper' , 'scissors']=>{
Copy link

@ericbarrs ericbarrs Oct 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid syntax

if (! choice) {
// User choice was undefined
return ("<p>Player 1, type in a correct input (rock, paper, or scissors).</p>");
} else {
// Display user choice
return("<p>Player 1:" + " " + choice + "</p>")
}
};

// 2. User2 input of rock, paper, or scissors.
const choice = ['rock', 'paper' , 'scissors']=>{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid syntex

if (! choice) {
// User choice was undefined
return ("<p>Player 2, type in a correct input (rock, paper, or scissors).</p>");
} else {
// Display user choice
return("<p>Player 2:" + " " + choice + "</p>")
}
};

// 3. Compare User1 input to User2 input.
const checkUserInput=()=>{

};

// 4. If User1 input is 'rock' and User2 input is 'scissor', User1 wins.
if (user1 === "rock") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statement not closed

if (user2 === "scissors") {
// rock wins
return "You win!";
} else {
// paper wins
return "You lose! Try again.";
}
};

// 5. If User1 input is 'rock' and User2 input is 'paper', User2 wins.
if (user1 === "rock") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statement not closed

if (user2 === "paper") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statement not closed

// paper wins
return "You win!";
};

// 6. If User1 input is 'rock' and User2 input is 'rock', it's a tie.
const compare = (hand1,hand2)=> {
if (hand1 === hand2) {
return "It's a tie!";
}

// 7. If User1 input is 'paper' and User2 input is 'rock', User1 wins.
if (user1 === "paper") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statement not closed

if (user2 === "rock") {
// paper wins
return "You win!";
}

// 8. If User1 input is 'paper' and User2 input is 'scissors', User2 wins.
if (user1 === "rock") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statement not closed

if (user2 === "scissors") {
// scissors wins
return "You win!";
}

// 9. If User1 input is 'paper' and User2 input is 'paper', it's a tie.
const compare = (hand1,hand2)=> {
if (hand1 === hand2) {
return "It's a tie!";
}

// 10. If User1 input is 'scissors' and User2 input is 'paper', User1 wins.
if (user1 === "scissors") {
if (user2 === "paper") {
// scissors wins
return "You win!";
}

// 11. If User1 input is 'scissors' and User2 input is 'rock', User2 wins.
if (user1 === "scissors") {
if (user2 === "rock") {
// rock wins
return "You win!";
}

// 12. If User1 input is 'scissors' and User2 input is 'scissors', it's a tie.
const compare = (hand1,hand2)=> {
if (hand1 === hand2) {
return "It's a tie!";
}

};



function getPrompt() {
rl.question('hand1: ', (answer1) => {
Expand Down