Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <script type="text/javascript">
  6. var playagain = true;
  7. var answer = 0;
  8. var useranswer = 0;
  9. var ask = "";
  10. while (playagain){
  11. answer = Math.floor(Math.random()*101);
  12. document.write(answer);
  13. do{
  14. useranswer = prompt("Please guess a number from 0-100.", "");
  15. if (answer > useranswer)
  16. document.write("...Sorry, you're wrong. Your guess of " + useranswer + "is too low");
  17. if (answer < useranswer)
  18. document.write("...Sorry, you're wrong. Your guess of " + useranswer + "is too high");
  19. document.write(answer);
  20. }while (useranswer != answer)
  21.  
  22. document.write("** Right ** " + answer + " is the magic number.");
  23. ask = prompt("Would you like to play again? Please type yes or no.", "");
  24. while (ask != "yes" && ask != "no")
  25. ask = prompt("Please type either yes or no to play again.", "");
  26. if (ask == "yes"){}
  27. if (ask == "no")
  28. playagain = false;
  29. }
  30. </script>
  31. <head>
  32.  
  33. <body>
  34.  
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement