I am creating a "Stone, Paper and Scissors" Game, I am in the final moment, but my code has an error that I can not identify.
var userChoice = prompt("Voce escolhe pedra, papel ou tesoura?");
var computerChoice = Math.random(1);
if (computerChoice < 0.34) {
computerChoice = "pedra";
} else if(computerChoice <= 0.67) {
computerChoice = "papel";
} else {
computerChoice = "tesoura";
} console.log("Computer: " + computerChoice);
var compare = function (choice1, choice2){
if(choice1 === choice2) {
return "O resultado e um empate";
}
else if(choice1 === "pedra") {
if(choice2 === "tesoura") {
return "pedra vence";
}
else {
return "papel vence";
}
}
else if(choice1 === "papel") {
if(choice2 === "pedra")
return "papel vence";
}
else {
return "tesoura vence";
};
else if(choice1 === "tesoura") {
if(choice2 === "pedra")
return "papel vence";
};
};