summary refs log tree commit diff
path: root/api/src/util/RandomInviteID.ts
blob: b37994d8ab2220e5915f063f71d310ed264abfa4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
export function random(length = 6) {
	// Declare all characters
	let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

	// Pick characers randomly
	let str = "";
	for (let i = 0; i < length; i++) {
		str += chars.charAt(Math.floor(Math.random() * chars.length));
	}

	return str;
}