# Need help with the tie part for Rock, Paper, Scissors

#1

I can't figure out how In this version, if both players make the same choice, the game returns a tie. What if the game didn't end there but instead asked both players for new choices?

``````var userChoice = prompt("Do you choose rock, paper or scissors?");

var computerChoice = Math.random();

if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

function compare(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
} else if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins";
} else {
return "paper wins";
}
} else if (choice1 === "paper") {
if (choice2 === "rock") {
return "paper wins";
} else {
return "scissors win";
}
} else if (choice1 === "scissors") {
if (choice2 === "paper") {
return "scissors win";
} else {
return "rock wins";
}
} else if (choice1 === "Rope") {
return "Rope ties everything up and user wins!";
}
else {
return "You did\'t choose correctly!";
}
}

compare(userChoice, computerChoice);``````

#2

The first line of your compare function checks for a tie between the computer and the player.

If you want to continue playing, well, then the exercise gets a little longer. Did you want to make a game that cycled until the user typed "quit"?

#3

I would like for another prompt to have the user choose again if the choice is a tie.

#4

This is beyond the exercise, of course, but you can loop your game reciprocally. If you wrap what you have in a function you can then re-call that function when you get a tie.

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.