Last active
January 13, 2016 22:27
-
-
Save danieluhl/db8ee0a5915a8f4235e4 to your computer and use it in GitHub Desktop.
Quick and dirty odds based lotto game
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 count = 0; | |
var run = function() { | |
var rand = Math.floor((Math.random() * 292000000)) + 1; | |
var check = 0; | |
while(true) { | |
check = Math.floor((Math.random() * 292000000)) + 1; | |
if(check === rand) { | |
break; | |
} | |
rand = Math.floor((Math.random() * 292000000)) + 1; | |
count++; | |
} | |
console.log('You spent ' + (count * 2).toLocaleString('en-US', { | |
style: 'currency', | |
currency: 'USD' | |
})); | |
console.log('Your luck is 1 in ' + count); | |
console.log('Given the 1.5B payout you made ' + (1500000000 - (count * 2)).toLocaleString('en-US', { | |
style: 'currency', | |
currency: 'USD' | |
})); | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment