Good afternoon! I'm doing a simple game of jokenpô
I created three inputs, one to enter the value that user wants and another to show what was selected by the program and last one to show the result.
I was able to get the value of the user and display the html value of the program, but I am not able to show the result in the last input? What would be the right way?
var textoUser = $("#txtFieldUser");
var textoGanhador = $("txtFieldGanhador");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "Pedra";
} else if(computerChoice <= 0.67) {
computerChoice = "Papel";
} else {
computerChoice = "Tesoura";
}
console.log("Computer: " + computerChoice);
var resultado = null;
var compare = function (choice1, choice2) {
if (choice1 === choice2)
return ("O resultado é 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 "pedra vence";
else {
return "tesoura vence";
}
}
};
compare(textoUser, computerChoice);