-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreeting-solution.html
More file actions
44 lines (36 loc) · 836 Bytes
/
greeting-solution.html
File metadata and controls
44 lines (36 loc) · 836 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
40
41
42
43
44
<!doctype html>
<html>
<head>
<title>JavaScript Greeting</title>
</head>
<body>
<h1>JavaScript Greeting</h1>
<script>
var now = new Date();
var day = now.getDay();
var hour = now.getHours();
document.write("<p>The current day is " + day + ".</p>");
document.write("<p>The current hour is " + hour + ".</p>");
if(day == 1)
{
document.write("<h2>Does someone have a case of the Mondays!</h2>");
}
else if(day == 5 && hour > 12)
{
document.write("<h2>TGIF!</h2>");
}
else if(day == 0 || day == 6)
{
document.write("<h2>Have a great weekend!</h2>");
}
else if(hour < 12)
{
document.write("<h2>Good morning!</h2>");
}
else
{
document.write("<h2>Good afternoon!</h2>");
}
</script>
</body>
</html>