File size: 334 Bytes
c33bf01
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
// Readable code chars — no 0/O, 1/I confusion
const CHARS = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';

function generateCode() {
  const part = (n) =>
    Array.from({ length: n }, () => CHARS[Math.floor(Math.random() * CHARS.length)]).join('');
  return `${part(4)}-${part(4)}`;  // e.g. AB3K-9X2M
}

module.exports = { generateCode };