-
Notifications
You must be signed in to change notification settings - Fork 0
/
mains.js
90 lines (87 loc) · 1.8 KB
/
mains.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"use-strict";
const btn = document.querySelector(".btn");
const excuse = document.querySelector(".excuse");
const btnFavorites = document.querySelector(".excuse_button");
const favorites = document.querySelector(".favorites");
const subject = [
"perro",
"iguana",
"chinchilla",
"nevera",
"compañero de piso",
"mejor amiga",
"vecina",
"silla",
"ukelele",
"lavadora",
"judia verde",
"pez",
"gato",
"cacatúa",
"hermana",
"sofá",
"escoba",
"estropajo",
"elfo doméstico",
"gamusino"
];
const verb = [
"comido",
"reciclado",
"borrado",
"enterrado",
"twiteado",
"robado",
"instagrameado",
"perdido",
"escrito sobre",
"bañado",
"escapado",
"casado",
"congelado",
"empaquetado",
"roto",
"tirado",
"mordido",
"cantado",
"saltado",
"escalado",
"volado"
];
const attribute = [
"el café",
"sus ataques de ansiedad",
"sus agobios",
"sus movidas",
"la felicidad",
"un familiar",
"los papeles",
"el coche",
"la bici",
"al miedo",
"la puerta",
"el váter",
"el enchufe",
"la varita",
"sus sentimientos",
"a un dinosaurio",
"un calcetín"
];
const whoDidWhat = a => a[Math.round(Math.random() * (a.length - 1))];
let currentExcuse;
const getExcuse = function() {
const who = whoDidWhat(subject);
const did = whoDidWhat(verb);
const what = whoDidWhat(attribute);
excuse.classList.remove("hidden");
document.getElementById("generator").innerHTML =
"<div>Mi " + who + " ha " + did + " " + what + ".</div>";
currentExcuse = document.getElementById("generator").innerHTML;
return currentExcuse;
};
function saveFavorites() {
favorites.innerHTML += `<li> ${currentExcuse}</li>`;
favorites.classList.remove("hidden");
}
btnFavorites.addEventListener("click", saveFavorites);
btn.addEventListener("click", getExcuse);