<script language="JavaScript"></script> <style type="text/css"> .style1 { font-family: Arial; font-size: x-small; } </style> </head> <body><p><script><!-- hide from old browser var inputText, feedback; // variables for holding user input and feedback var inputValue, loopCounter, correctCount, temp; // integer variables loopCounter = 0; // set the starting value of variables correctCount = 0; var num1, num2; num1 = Math.round(Math.random()*100); num2 = Math.round(Math.random()*100); inputText = window.prompt("What's " + num1 + " plus " + num2 + "? Enter -1 to stop.", "0"); inputValue = parseInt(inputText); while (inputValue != -1){ temp = num1 + num2; if (inputValue == temp){ correctCount++; feedback = "Correct! "; } else if (inputValue != temp) { feedback = "Sorry. Not correct"; } loopCounter++; num1 = Math.round(Math.random()*100); num2 = Math.round(Math.random()*100); inputText = ""; inputText = window.prompt("" + feedback + "Now, what's " + num1 + " plus " + num2 + "? (Enter -1 to stop:)", "0"); inputValue = 0; inputValue = parseInt(inputText); } document.write("<font size='5' color='#0000FF'><b>You have got " + correctCount + " correct out of " + loopCounter + " tries.</b></font>")
if (inputValue = temp)
if (inputValue == temp)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)