Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <script type="text/javascript">
- var playagain = true;
- var answer = 0;
- var useranswer = 0;
- var ask = "";
- while (playagain){
- answer = Math.floor(Math.random()*101);
- document.write(answer);
- do{
- useranswer = prompt("Please guess a number from 0-100.", "");
- if (answer > useranswer)
- document.write("...Sorry, you're wrong. Your guess of " + useranswer + "is too low");
- if (answer < useranswer)
- document.write("...Sorry, you're wrong. Your guess of " + useranswer + "is too high");
- document.write(answer);
- }while (useranswer != answer)
- document.write("** Right ** " + answer + " is the magic number.");
- ask = prompt("Would you like to play again? Please type yes or no.", "");
- while (ask != "yes" && ask != "no")
- ask = prompt("Please type either yes or no to play again.", "");
- if (ask == "yes"){}
- if (ask == "no")
- playagain = false;
- }
- </script>
- <head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement