-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
19 lines (16 loc) · 867 Bytes
/
Copy pathapp.js
File metadata and controls
19 lines (16 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
window.onload = function() {
// Arrays de datos
let who = ['The dog', 'My grandma', 'The mailman', 'My bird'];
let action = ['ate', 'peed', 'crushed', 'broke'];
let what = ['my homework', 'my phone', 'the car'];
let when = ['before the class', 'when I was sleeping', 'while I was exercising', 'during my lunch', 'while I was praying'];
// Selección aleatoria de cada parte
let rdmWho = who[Math.floor(Math.random() * who.length)];
let rdmAction = action[Math.floor(Math.random() * action.length)];
let rdmWhat = what[Math.floor(Math.random() * what.length)];
let rdmWhen = when[Math.floor(Math.random() * when.length)];
// Construcción de la frase
let fullExcuse = rdmWho + " " + rdmAction + " " + rdmWhat + " " + rdmWhen;
// Inyectar en el HTML
document.querySelector("#excuse").innerHTML = fullExcuse;
};