|
<SCRIPT>
// Define variables for the rest of
script
var question = "What is 10 + 10?";
var answer = 20;
var correct = '<IMG SRC="correct.gif">';
var incorrec = '<IMG SRC="incorrec.gif">';
// Ask the Question
var response = prompt(question,
"0");
// Check the answer the first time
if (response != answer) {
// The Answer was
wrong: offer a second chance
if (confirm("Wrong!
Press OK for a second chance.")) {
response = prompt(question,
"0");
}
}
// Check the answer
var output = (response == answer) ? correct : incorrec;
</SCRIPT>
<BODY>
<SCRIPT>
// Output the result
document.write(output);
</SCRIPT> |