How do I create a random string in typescript consisting of the alphabet [a-z0-9]? It should always consist of 32 digits. And also there should be no redundant strings.
How do I create a random string in typescript consisting of the alphabet [a-z0-9]? It should always consist of 32 digits. And also there should be no redundant strings.
Try this:
makeString(): string {
let outString: string = '';
let inOptions: string = 'abcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i++) {
outString += inOptions.charAt(Math.floor(Math.random() * inOptions.length));
}
return outString;
}
result: string = this.makeString();