|
<SCRIPT>
var question = "What is 10 + 10?";
var answer = 20;
var correct = '<IMG SRC="images/correct.gif">';
var incorrec = '<IMG SRC="images/incorrec.gif">';
// ask the Question
var response = prompt(question,
"0");
// check the first answer
if (response != answer) {
// the answer was
wrong: offer a second chance
if (confirm("Wrong!
Press OK for a second chance."))
response = prompt(question,
"0");
}
else {
// the answer was
right: offer a second Question
if (confirm("Correct!
Press OK for a second question.")) {
question =
"What is 10 * 10?";
answer = 100;
response = prompt(question,
"0");
}
}
// check the answer
var output = (response == answer) ? correct : incorrec;
</SCRIPT>
<BODY>
<SCRIPT>
document.write(output);
</SCRIPT> |