Skip to content

Instantly share code, notes, and snippets.

@kino6052
Created April 26, 2020 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kino6052/3e52741d0bbe8e0f6436ff4028755d28 to your computer and use it in GitHub Desktop.
Save kino6052/3e52741d0bbe8e0f6436ff4028755d28 to your computer and use it in GitHub Desktop.
const getRandomNumbers = (length: number) => {
const value = Array.from(Math.round(Math.random()*(Math.pow(10, length))).toString()).reverse();
return new Array(length).fill('0').map((v, i) => value[i] || v).reverse().join('');
}
const generateId = (amount: number, length: number) => new Array(amount).fill(0).map((a, i, b) => `${i && '-'}${getRandomNumbers(length)}`).join('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment