xonecas.io
4436
Sl

sesame-labs-coding-assignment / files

sesame-labs-coding-assignment / api / src / quest / util.ts

273 bytes
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};