Skip to content

Instantly share code, notes, and snippets.

@danieluhl
Last active January 13, 2016 22:27
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 danieluhl/db8ee0a5915a8f4235e4 to your computer and use it in GitHub Desktop.
Save danieluhl/db8ee0a5915a8f4235e4 to your computer and use it in GitHub Desktop.
Quick and dirty odds based lotto game
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