Skip to content

Instantly share code, notes, and snippets.

@adamkirkwood
Created August 9, 2010 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamkirkwood/516229 to your computer and use it in GitHub Desktop.
Save adamkirkwood/516229 to your computer and use it in GitHub Desktop.
var firstName = prompt("Hi! What\'s your first name?");
var lastName = prompt("Hi! What\'s your last name?");
var randNumA = null;
var randNumB = null;
var randNumC = null;
var answer=confirm("Hi " + firstName + " \nWould you like to try your luck?");
while(answer) {
generateNumbers();
checkNumbers();
}
function generateNumbers() {
randNumA = Math.floor(Math.random()*11);
randNumB = Math.floor(Math.random()*11);
randNumC = Math.floor(Math.random()*11);
}
function checkNumbers() {
if ((randNumA == randNumB) && (randNumB == randNumC)) {
alert(firstName + " " + lastName + " you are a WINNER!");
}
else if ((randNumA == randNumB) || (randNumB == randNumC) || (randNumA == randNumC)) {
alert(firstName + " " + lastName + " you are Getting Warmer");
}
else {
answer=confirm(firstName + " \nWould you like to try again?");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment