Check Answer Twice With Prompt

[Total: 0    Average: 0/5]

This shows how to check the input from the user twice before stating (s)he is wrong.

Body Code:

<SCRIPT type=text/javascript>
function test() {
  var _r = "Correct!";
  var _n1 = 10;
  var _n2 = 4;
  var _a = prompt("What is "+_n1+"+"+_n2+"?","");
  if (_a != (_n1+_n2))
     _a = prompt("Are you sure? - Enter in "+_n1+"+"+_n2+" again:","");
    if (_a != (_n1+_n2))
      _r = "No! - It is "+(_n1+_n2);
  alert(_r);
}
</script>
<a href="javascript:test()">START TEST</a>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *