Created
February 24, 2011 15:22
-
-
Save nbashaw/842292 to your computer and use it in GitHub Desktop.
guessing game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var answer = Math.floor(Math.random()*11); | |
var guesscount = 0; | |
while (guess != answer) { | |
var guess = Number(prompt("Guess what number I'm thinking of.")); | |
var guesscount = guesscount + 1; | |
if (guess > answer){ alert("Too high!"); } | |
else if (guess < answer){ alert("Too low!"); } | |
else { alert("You guessed it! Only took you " + guesscount + " guesses."); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment