Skip to content

Instantly share code, notes, and snippets.

View amadeuszblanik's full-sized avatar
👨‍💻
Working remotely

Amadeus Blanik amadeuszblanik

👨‍💻
Working remotely
View GitHub Profile
@amadeuszblanik
amadeuszblanik / idGenerator.ts
Created March 3, 2020 10:00
[TypeScript] Generate random ID
export const idGenerator = (length: number) => {
const allowedCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
let response: string = ""
for (let i = 0; i < length; i++) {
const {length: charLength} = allowedCharacters
response += allowedCharacters.charAt(Math.floor(Math.random() * charLength))
}
return response