- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreeting-message.html
More file actions
Latest commit
45 lines (38 loc) · 1.22 KB
/
Copy pathgreeting-message.html
File metadata and controls
45 lines (38 loc) · 1.22 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
<!DOCTYPE html>
<htmllang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<metacharset="utf-8" />
<title>Greeting Message</title>
<scripttype="text/javascript">
//1. Declaration
varname;//String entered by the user
vartoday;//Stroe date object
vartheHour;//contains current hour
//2. Initialization
name=window.prompt("Please enter your name"," Elmira");
today=newDate();
theHour=today.getHours();
//3.Proccessing
//determine if it is morning
if(theHour<12){
document.writeln("<h2> Good Morning, ");
}
//determing whether the time is PM
if(theHour>=12){
//convert to 12 format hour clock
theHour=theHour-12;
//determine whether it is before 6 pm
if(theHour<6){
document.writeln("<h2> Good Afternoon, ");
}
if(theHour>=6){
document.writeln("<h2> Good evening, ");
}
}//end outer if whether it is after 6 pm
//4 . Out put
document.writeln(name+" , Welcome back! </h2>");
</script>
</head>
<body>
</body>
</html>