I am trying to make a guessing game where the computer generates a random number and you guess it. The problem is, anytime it makes a "random number," it generates a 1, 9, or 10. I keep testing this and it only gives me one of those three values. What should I do to make this more random?
Math.floor(Math.random() * 10) + 1;
I want it to have it more randomized and have a 3, 6, 4 or other number some times, not just a 1, 9, or 10.
var hiddenNumber = Math.floor(Math.random() * 10) + 1;
function guessFunction() {
var input1 = document.getElementById("input1").value;
if (input1 == hiddenNumber) {
alert("Great Job!");
} else if (input1 > hiddenNumber) {
alert("Your Number Is Too High. Go Lower!");
} else {
alert("Your Number Is Too Low. Go Higher!");
}
}
document.getElementById("enterButton").addEventListener("click", guessFunction);
Aucun commentaire:
Enregistrer un commentaire