forked from CodeYourFuture/Module-Data-Groups
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (40 loc) · 1.22 KB
/
script.js
File metadata and controls
47 lines (40 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
46
47
// for the tests, do not modify this array of books
const books = [
{
title: "The Design of Everyday Things",
author: "Don Norman",
alreadyRead: false,
bookCoverImage: "https://blackwells.co.uk/jacket/l/9780465050659.jpg",
},
{
title: "The Most Human Human",
author: "Brian Christian",
alreadyRead: true,
bookCoverImage:
"https://images-na.ssl-images-amazon.com/images/I/41m1rQjm5tL._SX322_BO1,204,203,200_.jpg",
},
{
title: "The Pragmatic Programmer",
author: "Andrew Hunt",
alreadyRead: true,
bookCoverImage: "https://blackwells.co.uk/jacket/l/9780135957059.jpg",
},
];
function readingList() {
const unorderedList = document.querySelector("#reading-list");
for (const book of books) {
const newList = document.createElement("li");
const newImage = document.createElement("img");
newImage.src = book.bookCoverImage;
const paragraph = document.createElement("p");
paragraph.textContent = `${book.title} by ${book.author}`;
newList.append(paragraph, newImage);
if (book.alreadyRead) {
newList.classList.add("read");
} else {
newList.classList.add("notRead");
}
unorderedList.appendChild(newList);
}
}
readingList();