Skip to content

Instantly share code, notes, and snippets.

@Astro36
Created January 18, 2020 14:13
Show Gist options
  • Save Astro36/be593eb9f0e10b2c0d4a87d0dcd14a85 to your computer and use it in GitHub Desktop.
Save Astro36/be593eb9f0e10b2c0d4a87d0dcd14a85 to your computer and use it in GitHub Desktop.
const date = new Date();
const seed = date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate();
let nums = [...new Array(50).keys()]; // [0, 1, 2, 3, ..., 29];
const rand = (() => {
let next = seed;
return () => (next = (1103515245 * next + 12345) % 10000000) % 3;
})();
console.log(nums.sort((a, b) => rand() - 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment