Skip to content

Instantly share code, notes, and snippets.

@nimitmaru
Last active August 29, 2015 14:15
Show Gist options
  • Save nimitmaru/5cc1b34f27c93fc3e6e7 to your computer and use it in GitHub Desktop.
Save nimitmaru/5cc1b34f27c93fc3e6e7 to your computer and use it in GitHub Desktop.
var getRandNumber = function () {
return Math.floor(Math.random()*100)+1;
};
var goal = getRandNumber();
jQuery("#guess").click(function() {
var usersGuess = jQuery("#user_input").val();
usersGuess = parseInt(usersGuess);
if(usersGuess < goal) {
alert('your guess is too low');
} else if (usersGuess > goal) {
alert('your guess is too high');
} else {
alert('you got it!');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment