Created
December 3, 2015 15:08
-
-
Save ThomasGreiner/c346d62f3096bc0b1e0f to your computer and use it in GitHub Desktop.
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
| "use strict"; | |
| function test() { | |
| let arr = ["a", "b", "c", "d", "e", "f"]; | |
| let result = []; | |
| while (arr.length) { | |
| let i = Math.floor(Math.random() * (arr.length - 1)); | |
| result.push(arr.splice(i, 1)[0]); | |
| } | |
| return result; | |
| } | |
| let result = { | |
| a: [0, 0, 0, 0, 0, 0], | |
| b: [0, 0, 0, 0, 0, 0], | |
| c: [0, 0, 0, 0, 0, 0], | |
| d: [0, 0, 0, 0, 0, 0], | |
| e: [0, 0, 0, 0, 0, 0], | |
| f: [0, 0, 0, 0, 0, 0] | |
| }; | |
| for (let i = 0; i < 1000000; i++) { | |
| let items = test(); | |
| for (let rank = 0; rank < items.length; rank++) { | |
| result[items[rank]][rank]++; | |
| } | |
| } | |
| console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment