-
-
Save tecteun/0716e8f6350b59aa1067 to your computer and use it in GitHub Desktop.
Open sourced code to determine who in the team gets the overige tim tams after everyone has had one
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 totalTimTamsinPack = 8; //For the Hellema brand | |
| var people = ["fardau", "wilfred", "jeroen", "teun", "arjan", "erik", "paul"]; | |
| var usecrypto = true; | |
| var timtamsleftAfterEveryoneGetsOne = totalTimTamsinPack - people.length; | |
| var array = new Uint32Array(1); | |
| while(timtamsleftAfterEveryoneGetsOne-- > 0){ | |
| var winer = null; | |
| if(usecrypto){ | |
| window.crypto.getRandomValues(array); | |
| winer = people[Math.floor(array[0]/ (0xFFFFFFFF / people.length))]; | |
| }else{ | |
| winer = people[Math.floor(Math.random()*people.length)] | |
| } | |
| alert("The " + (timtamsleftAfterEveryoneGetsOne + 1 )+ "nd last tim tam goes to " + winer); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment