Created
January 13, 2016 23:10
-
-
Save danieluhl/8710c54c9814bc8dc3f8 to your computer and use it in GitHub Desktop.
HTML version of luck tester
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
<input id="button" type="button" value="WHAT'S MY LUCK!?!" onclick="return window.run()" /> | |
<h1 id="results"></h1> | |
<script type="text/javascript"> | |
var count = 0; | |
var result = ''; | |
window.run = function() { | |
console.log('running'); | |
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++; | |
} | |
result = 'You spent ' + (count * 2).toLocaleString('en-US', { | |
style: 'currency', | |
currency: 'USD' | |
}); | |
result = result + '<br />Your luck is 1 in ' + count | |
result = result + '<br />Given the 1.5B payout you made ' + (1500000000 - (count * 2)).toLocaleString('en-US', { | |
style: 'currency', | |
currency: 'USD' | |
}); | |
document.getElementById('results').innerHTML=result; | |
document.getElementById('button').value='TRY AGAIN?'; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment