-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathname-gen.js
30 lines (30 loc) · 1.05 KB
/
name-gen.js
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
function generateName() {
fetch("adjektiv.txt")
.then(response => response.text())
.then(text => {
const adjektiv = text.split("\n");
fetch("substantiv.txt")
.then(response => response.text())
.then(text => {
const substantiv = text.split("\n");
let resultAdjektiv = adjektiv[
Math.floor(Math.random() * adjektiv.length)
].replace(/(\r\n|\n|\r)/gm, "");
resultAdjektiv =
resultAdjektiv.charAt(0).toUpperCase() + resultAdjektiv.slice(1);
let resultSubstantiv = substantiv[
Math.floor(Math.random() * substantiv.length)
].replace(/(\r\n|\n|\r)/gm, "");
resultSubstantiv =
resultSubstantiv.charAt(0).toUpperCase() +
resultSubstantiv.slice(1);
const result =
resultAdjektiv +
resultSubstantiv +
Math.floor(Math.random() * 9) +
Math.floor(Math.random() * 9);
document.getElementById("name").innerText = result;
});
});
}
generateName();