Skip to content

Instantly share code, notes, and snippets.

@icetee
Created October 14, 2021 14:33
Show Gist options
  • Save icetee/56f0c343e3c88f9323d22ea1f856bccc to your computer and use it in GitHub Desktop.
Save icetee/56f0c343e3c88f9323d22ea1f856bccc to your computer and use it in GitHub Desktop.
Get random serial numbers
let count = 10100;
let prefix = "KGY"
let keys = [];
let getRandomNumber = () => ("0000" + Math.round(Math.random() * 10000)).slice(-4)
do {
let randomKey = prefix + "-" + getRandomNumber() + "-" + getRandomNumber();
if (keys.indexOf(randomKey) === -1) {
keys.push(randomKey)
}
} while (keys.length < count);
copy(keys.join("\n"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment