Title is self explanatory - I cannot figure out how to get this code working. Any help?
HTML Code:<html> <head> <title> Addition </title> </head> <script> var guess = -1; // Set guess to a value outside the range of valid values 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; alert("(to help test) The correct answer is " + sum); // Just to help test // Use a while loop while (guess != sum) { guess = prompt("Guess a number from 1 to 10", ""); if (guess == sum) { alert("Correct!"); } else if (guess < sum) { alert("Guess higher "); } else { alert("Guess lower"); } } </script> </body> </html>


Reply With Quote
Bookmarks