Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save julienreszka/c6c42acca86239f136031e8f681ec4b7 to your computer and use it in GitHub Desktop.
Save julienreszka/c6c42acca86239f136031e8f681ec4b7 to your computer and use it in GitHub Desktop.
Useful for creating Google-like Payments profile ID
var getRandom4 = () => String(Math.round(Math.random(1000,9999) * 100000)).slice(0,4)
var get3Random4SeparatedByDashes = () => [getRandom4(),getRandom4(),getRandom4()].join('-')
get3Random4SeparatedByDashes()
// '1610-6631-6374' // for example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment