-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNameGenerator.ts
38 lines (35 loc) · 1.46 KB
/
NameGenerator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const starts = ["a", "b", "c", "d", "e", "f", "g", "i", "j", "k", "l", "m", "n", "o", "r", "p", "s", "t", "u"]
const speakable ={
"a": ["b", "d", "f", "g", "h", "i", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u"],
"b": ["a", "e", "i", "l", "o", "r", "u"],
"c": ["h"],
"d": ["a", "e", "i", "l", "o", "r", "u"],
"e": ["f", "i", "j", "k", "m", "n", "p", "r", "s", "t", "u"],
"f": ["a", "e", "i", "l", "o", "r", "u"],
"g": ["a", "e", "i", "l", "o", "u"],
"h": ["a", "e", "i", "o", "u"],
"i": ["b", "f", "k", "l", "m", "n", "p", "r", "h", "s", "t"],
"j": ["a", "e", "i", "o", "u"],
"k": ["a", "e", "i", "l", "o", "u"],
"l": ["a", "e", "i", "o", "u"],
"m": ["a", "e", "i", "l", "o", "u"],
"n": ["a", "e", "i", "o", "u"],
"o": ["b", "c", "f", "g", "h", "i", "j", "k", "l", "m", "n", "p", "r", "s", "t"],
"p": ["a", "e", "i", "l", "o", "r", "u"],
"r": ["a", "e", "i", "o", "u"],
"s": ["a", "e", "c", "i", "o", "u", "t"],
"t": ["a", "e", "i", "o", "u"],
"u": ["b", "g", "i", "k", "n", "m", "p", "r", "s", "t"],
}
const minLength = 5
const maxLength = 10
function generateName() {
const length = Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength
let char = starts[Math.floor(Math.random() * starts.length)]
let word = char
for (let i = 0; i < length; i++) {
char = speakable[char][Math.floor(Math.random() * speakable[char].length)]
word += char
}
return word
}