sesame-labs-coding-assignment / api / src / quest / util.ts
1import { randomInt } from "crypto"; 2 3const SLUG_ALPHABET = "abcdfghjkmnpqrstvwxz0123456789".split(""); 4 5export const getCouponCode = (length = 10) => { 6 return new Array(length) 7 .fill(0) 8 .map(() => SLUG_ALPHABET[randomInt(SLUG_ALPHABET.length)]) 9 .join(""); 10};