Skip to content

Instantly share code, notes, and snippets.

@caseybecking
Created October 30, 2013 02:58
Show Gist options
  • Save caseybecking/7226565 to your computer and use it in GitHub Desktop.
Save caseybecking/7226565 to your computer and use it in GitHub Desktop.
Sample Code for Mike
var theNumber = Math.floor(Math.random() * 20 + 1);
var count = 0;
var trys = 5;
function Submit() {
var submit = document.getElementById('submit');
var output = document.getElementById('output');
var myNumber = submit.value;
if (count < trys) {
if (myNumber < theNumber) {
alert("Too Low! Try again.");
}
else if (myNumber > theNumber) {
alert("Too high, try again");
}
else if (myNumber == theNumber) {
alert("That's the Number! Play Again");
theNumber = Math.floor(Math.random() * 20 + 1);
}
}else{
submit.disabled = true;
alert("Sorry no more trys");
}
count++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment