Skip to content

Instantly share code, notes, and snippets.

@alacritythief
Created September 15, 2014 16:57
Show Gist options
  • Save alacritythief/b5ea3c3fe2362442b4a6 to your computer and use it in GitHub Desktop.
Save alacritythief/b5ea3c3fe2362442b4a6 to your computer and use it in GitHub Desktop.
Guess the Number
var randomNumber = Math.floor(Math.random()*101);
var userName = prompt("What is your name?");
var guess = prompt("Please guess a number 1 - 100:");
if (guess == randomNumber) {
alert(userName + ", you guessed correctly! You win!");
} else {
alert(userName + ", that is the wrong number! You lose!");
}
<!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