-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter7assign.htm
More file actions
110 lines (95 loc) · 1.89 KB
/
chapter7assign.htm
File metadata and controls
110 lines (95 loc) · 1.89 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE>
<html>
<head>
<title>Chapter 7 Assignment</title>
<script type="text/javascript">
function stars()
{
for(var s=1; s<=50; s++)
{
document.write("*");
}
document.write("</br>");
}
var books = ["War and Peace", "Huckleberry Finn", "The Return of the Native", "A Christmas Carol", "Exodus"];
var authors = [];
for(var i=0; i<books.length; i++)
{
authors[i] = prompt("Enter the last name of the author that wrote "+books[i]+":","");
}
stars();
for(var n=0; n<books.length; n++)
{
document.write("<b>Book: </b>"+books[n]+"<b> Author: </b>"+authors[n]+"</br>");
}
stars();
var author_title =
[ ["Tolstoy", "War and Peace"],
["Twain", "Huckleberry Finn"],
["Hardy", "The Return of the Native"],
["Dickens", "A Christmas Carol"],
["Uris", "Exodus"]
];
for(var i=0; i<author_title.length; i++)
{
for(var j=0; j<author_title[i].length; j++)
{
if (j===0)
{
document.write(author_title[i][j] + " wrote ");
}
else if (j===author_title[i].length -1)
{
document.write(author_title[i][j]+"<br>");
}
else
{
continue;
}
}
}
stars();
author_title.pop();
for(var i=0; i<author_title.length; i++)
{
for(var j=0; j<author_title[i].length; j++)
{
if (j===0)
{
document.write(author_title[i][j] + " wrote ");
}
else if (j===author_title[i].length -1)
{
document.write(author_title[i][j]+"<br>");
}
else
{
continue;
}
}
}
stars();
author_title.sort();
for(var i=0; i<author_title.length; i++)
{
for(var j=0; j<author_title[i].length; j++)
{
if (j===0)
{
document.write(author_title[i][j] + " wrote ");
}
else if (j===author_title[i].length -1)
{
document.write(author_title[i][j]+"<br>");
}
else
{
continue;
}
}
}
stars();
</script>
</head>
<body></body>
</html>