Created
August 9, 2010 22:15
-
-
Save adamkirkwood/516229 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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