I'm doing a little game based on question-answers with 3 options. First of all, I was trying to just randomize the position of the right answer. But, after a long time trying, I decided to just add the value after the randomization of the buttons and give the right value for the right button. But, while I'm doing it, the other 2 wrong answers have the same value. The code:
<main>
<p>Number pi</p>
<input type="submit" value="" id='btn1'>
<input type="submit" value="" id='btn2'>
<input type="submit" value="" id='btn3'>
</main>
var random = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
for(var i=1;i<=3;i++) {
console.log(i);
var button = document.getElementById('btn' + i);
if(random == i) {
button.addEventListener('click', acerto);
button.value = '3.14';
}
else {
button.addEventListener('click', erro);
button.value = '2.14';
}
}
So, how can I give 2 different values for the 2 wrong buttons? Like, '3.14' is the right one and the 2 others are '2.14' or '4.14'