The result is always tie


#1

Hi, my problem is another, i'm trying to have my own game, but the first risult is always a tie. I think that this is statistically impossibile :stuck_out_tongue: Here is my code, what is wrong?

var userChoice = prompt("Do you choose rock, paper or scissors?");
if (userChoice != "rock" && userChoice != "paper" && userChoice != "scissors" ) {
var userChoice = prompt("Please enter rock, paper or scissors!")
}
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
}
var compare = function(choice1,choice2) {
if (choice1 === choice2) {
return ("The result is a tie!");
}  prompt("The result is a tie! Try again! Do you choose rock, paper or scissors?");

if (choice1 === "rock") {
if (choice2 === "scissors") {
return ("rock wins");
}
else {
return ("paper wins");
}
}
if (choice1 === "paper") {
if (choice2 === "rock") {
return ("paper wins");
}
else {
return ("scissors wins");
}
}
if (choice1 === "scissors") {
if (choice2 === "rock") {
return ("rock wins");
}
else {
return ("scissors wins");
}
}
};
compare(userChoice,computerChoice);

Rock, paper, scissors part 9, next steps
#2

Ok, I moved this question to a different topic as it is a question on it's own.
And about the question itself: Well have a look at these lines:

if (choice1 === choice2) {
return ("The result is a tie!");
}  prompt("The result is a tie! Try again! Do you choose rock, paper or scissors?");

So as the prompt is not inside of the if you'll always get the message when the result is not a tie.