I'm a Digital Arts student, I'm in my first year and recently we've been given the task to make a basic E-Learning website for maths. Basically you're asked what (for example) 7 times 7 is, you enter the answer and click a button, an alert window comes up. If you're correct it's supposed to say "correct" or "yay" or "well done" and if you're wrong it says "No" or "try again" or something else.
My problem is that it's supposed to show one random message in the window alert, not all of them at once or one after the other, just one randomly. I've looked but I wasn't able to find anything that helps.
Here's the part of the code I'm having trouble with:
<script type="text/javascript">
var x, y;
var answer;
function aNumber() {
return Math.floor(1 + (Math.random() * 12));
}
function genQuestion() {
x = aNumber();
y = aNumber();
din = document.getElementById("inputVal");
din.value = x + " times " + y;
answer = x * y;
}
function ClickAnswer() {
if (answer == document.getElementById("outputVal").value) {
window.alert("Correct");
window.alert("Yes!");
window.alert("Well done");
location.reload();
} else {
window.alert("No, try again.");
window.alert("try again");
window.alert("wrong");
}
}
function displayArea() {
din = document.getElementById("inputVal");
dout = document.getElementById("outputVal");
dout.value = circleArea(din.value);
}
</script>