Hi so I have this nifty lab I am doing, and I got it working very well. However, I cannot figure out how to ask the user if they want to play again. Any help?
HTML Code:<html> <head> <title> Lab 11 - #3 </title> </head> <script> var guess = -1; // Set guess to a value outside the range of valid values for (i=1; i <= 5; i++) { var num1 = parseInt(Math.random()*10); // get a number between 0 and 9 var num2 = parseInt(Math.random()*10); // get a number between 0 and 9 sum = num1 + num2; // Use a while loop while (guess != sum) { guess = prompt("Enter the correct answer for "+num1+" + "+num2, '') if (guess == sum) { alert("Correct!"); } else if (guess < sum) { alert("Guess higher "); } else { alert("Guess lower"); } } } if (confirm("Play again?")) { document.reset( ); } </script> </body> </html> ?


Reply With Quote
Bookmarks