This Gist was automatically created by Carbide, a free online programming environment.
Last active
August 25, 2016 08:27
-
-
Save olekenneth/abd932ed33ce63e6377fa9cfa2bfd289 to your computer and use it in GitHub Desktop.
Random picker
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 t = ""; | |
| var testRandom = function(times, every) { | |
| var i = 0; | |
| var number = 0; | |
| while(times > i) { | |
| if (Math.floor(Math.random() * every) === (every - 1)) { | |
| number++; | |
| } | |
| i++; | |
| } | |
| t += "Picked: " + number + " - Ran: " + i; | |
| document.write(t); | |
| }; | |
| testRandom(1000,5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment