Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. var number = Math.floor((Math.random()* 20) + 1);
  2. var name = prompt("What is your name?")
  3. var guess = prompt("Guess a number, 1 through 20")
  4.  
  5. if (guess == number){
  6. alert("You win " + name + "!");
  7. } else {
  8. alert("You lose " + name + "!")
  9. }
  10.  
  11.  
  12.  
  13. #index.html
  14.  
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18. <title>Guess the Number</title>
  19. </head>
  20.  
  21. <body>
  22. <script src="guess_the_number.js"></script>
  23. </body>
  24. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement