|
Alright, after experimenting with functions, this is what I have, now when its executed, it now gives the user a new question each time they answer correctly, and puts "yes, your correct" into the status bar.
However, if the user answers incorrectly, and answers right on the 2nd or Nth try, it does give them a new question, but wont change on the status bar (still says "No, try again")
document.write( myfunc() );
function myfunc() {
number1 = Math.floor( 1+ Math.random() * 9 );
number2 = Math.floor( 1+ Math.random() * 9 );
number3 = number2 * number1;
document.writeln("<h1>How much is " + number1 + " and " + number2 + "?</h1>" );
answer = document.writeln( "Correct answer?" );
document.write( myfunc2() );
return;
}
function myfunc2() {
if ( number3 == answer ) {
window.status = "Very good!";
document.write( myfunc() );
}
else if ( number3 != answer) {
window.status = "No. Please try again."
answer = window.prompt( "Correct answer?" );
document.write( myfunc() );
}
}
|