Skip to content

Instantly share code, notes, and snippets.

@ismaelsadeeq
Last active May 12, 2022 09:15
Show Gist options
  • Save ismaelsadeeq/8b32aba0a3cadd31c7f86ef7d8e3e4b1 to your computer and use it in GitHub Desktop.
Save ismaelsadeeq/8b32aba0a3cadd31c7f86ef7d8e3e4b1 to your computer and use it in GitHub Desktop.
function generateId(startIn?: number){
startIn? null: startIn = 1
if(startIn>1000000){
return false;
}
let randomId:number = 100000+Math.floor(Math.random() * 9000000);
if(startIn>0){
while(randomId < startIn){
randomId = 100000+Math.floor(Math.random() * 9000000)
}
}
return randomId.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment