Hello, I'm writing a page with a Stone or Scissors game. And I would like the user to be able to choose between the three options through three buttons, which when clicked call a function that assigns a value to the variable relative to the user's move, and then makes comparisons to know who won (Computer or User). My problem is that I can not get the variable to receive the values equivalent to plays using the functions.
Note: My algorithm for comparing the plays of both the PC and the User is working, so I did not post it together.
var a = 0;
function Pedra() {
return a = 1;
}
function Papel() {
return a = 2;
}
function Tesoura() {
return a = 2;
}
if (a == 1) {
alert("pedra");
}
if (a == 2) {
alert("Papel");
}
if (a == 3) {
alert("tesoura");
}
<div>
<div>
<button type="button" onclick="Pedra()">Pedra</button>
</div>
<div id="papel">
<button type="button" onclick="Papel()">Papel</button>
</div>
<div id="tesoura">
<button type="button" onclick="Tesoura()">Tesoura</button>
</div>
</div>