|
<SCRIPT>
// define variables for the rest of the
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> |