-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgreeting.js
38 lines (36 loc) · 1.04 KB
/
greeting.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
var hours = new Date().getHours();
var message;
var graveyard = [
"Staying up all night?",
"Want a late-night snack?",
"Don't stay up too late!",
"Delivery too expensive?",
];
var morning = [
"Fancy some breakfast?",
"Is breakfast really the most important meal of the day?",
"What do you want to eat?",
"Have a good morning!",
];
var afternoon = [
"What do you want for lunch?",
"What do you want to eat?",
"Have a good afternoon!",
"Use those blocks!",
];
var evening = [
"What do you want for dinner?",
"What do you want to eat?",
"Have a good evening!",
"Grab a bite to eat!",
];
if (hours >= 0 && hours < 6) {
message = graveyard[Math.floor(Math.random() * graveyard.length)];
} else if (hours >= 6 && hours < 12) {
message = morning[Math.floor(Math.random() * morning.length)];
} else if (hours >= 12 && hours < 17) {
message = afternoon[Math.floor(Math.random() * afternoon.length)];
} else if (hours >= 17 && hours < 24) {
message = evening[Math.floor(Math.random() * evening.length)];
}
$(".greeting").append(message);