-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (47 loc) · 1.41 KB
/
Copy pathscript.js
File metadata and controls
48 lines (47 loc) · 1.41 KB
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
const excuses={
personal:[
"I have a family emergency.",
"I suddenly got a headache",
"My phone battery died."
],
school:[
"My assignment file got corrupted",
"My internet stopped working",
"I submitted it but mybe it didn't upload."
],
dating:[
"I got stuck in traffic",
"My phone was on silent",
"I had an unexpected call"
],
funny:[
"My cat walked on the keyboard",
"My alarm clock betrayed me",
"My brain decided to take a holiday"
],
work:[
"My system suddenly crashed",
"The server was down",
"I was debugging another issue"
],
silly:[
"A pigeon attacked my window",
"My chair broke suddenly",
"I got destracted by a meme"
]
};
function generateExcuse(){
const category=document.querySelector('input[name="category"]:checked');
if(!category){
alert("Please select a category");
return;
}
const selectedCategory=category.value;
const categoryExcuses=excuses[selectedCategory];
const randomIndex= Math.floor(Math.random()*categoryExcuses.length);
const excuse=categoryExcuses[randomIndex];
const display=document.getElementById("excuse-display");
display.style.display="block";
display.textContent=excuse;
}
document.getElementById("generate").addEventListener("click", generateExcuse);