-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmPmCheck.html
More file actions
39 lines (38 loc) · 1022 Bytes
/
AmPmCheck.html
File metadata and controls
39 lines (38 loc) · 1022 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
const date = new Date();
const hour = date.getHours();
const check = hour <= 12;
if (check) {
alert(`${hour}오전입니다.`);
}
if (!check) {
alert(`${hour}오후입니다.`);
}
alert("종료");
const breakfast = 7 <= hour && hour <= 9;
const lunch = 11 <= hour && hour <= 13;
const dinner = 18 <= hour && hour <= 20;
if (breakfast) {
alert("아침을 먹을 시간입니다.");
}
if (lunch) {
alert("점심을 먹을 시간입니다.");
}
if (dinner) {
alert("저녁을 먹을 시간입니다.");
}
if (!breakfast && !lunch && !dinner) {
alert("지금은 밥먹을 시간이 아닙니다");
}
alert("종료");
</script>
</body>
</html>