Created
June 19, 2014 01:33
-
-
Save Murphydbuffalo/eeb925b50c8af09aaacc to your computer and use it in GitHub Desktop.
Guess the number
This file contains hidden or 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
function getInput() { | |
prompt('Please guess a number between 1 and 100.'); | |
} | |
var name = prompt('Welcome! What\'s your name?'); | |
var secretNumber = (Math.floor(Math.random() * 100) + 1); | |
while(!name.length > 0) { | |
name = prompt("Enter something for a name :)") | |
} | |
alert('Hi, ' + name + '.') | |
for(var input = getInput(); input != secretNumber; input = prompt('Guess again!')){ | |
if(input < secretNumber){ | |
alert('Too low!'); | |
} | |
else if(input > secretNumber) { | |
alert('Too high!'); | |
} | |
} | |
alert('You got it!'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment