Skip to content

Instantly share code, notes, and snippets.

@foglabs
Last active August 29, 2015 14:06
Show Gist options
  • Save foglabs/27fe2f1dc86aa5d9310f to your computer and use it in GitHub Desktop.
Save foglabs/27fe2f1dc86aa5d9310f to your computer and use it in GitHub Desktop.
Guess Tha Numbah JS
var secretNumber = Math.random()*100;
secretNumber = Math.round(secretNumber);
var name = prompt("What's yo name baby?");
for(i = 0; i < 10; i++) {
var guess = prompt("Enter your guess, baby!");
if(guess == secretNumber) {
alert(name + ' wins!!!!');
i = 10;
}
if(guess > secretNumber) {
alert('Too High!');
}
if(guess < secretNumber) {
alert('Too Low!');
}
}
if(guess != secretNumber) {
alert("You're garbage!");
}
<!DOCTYPE html>
<html>
<head>
<title>Guess the Number</title>
</head>
<body>
<script src="guess_the_number.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment