I'm making a program that generates two random numbers and asks the user to provide the answer to the two numbers multiplied. I have managed to get the number generator to work and the correct answer is displayed but the checker isn't working correctly. I'd also like it to show a message if nothing was entered into the answer box. Any help would be great, thanks!
var x, y;
function generateNumbers() {
function getRandom12() {
return Math.floor((Math.random() * 12) + 1);
}
x = getRandom12();
y = getRandom12();
}
function genQuestion() {
generateNumbers();
document.getElementById('question').value = x + " times " + y;
}
function buttonPressed() {
if (answer == x * y)
{
window.alert("yes");
}
else {
window.alert("no");
}
}
Aucun commentaire:
Enregistrer un commentaire