Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 189c65d

Browse files
committed
reading list is done
1 parent 3511f66 commit 189c65d

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

week-3/reading-list/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link rel="stylesheet" href="style.css" />
7-
<title>Title here</title>
7+
<title>Reading list app</title>
88
</head>
99
<body>
1010
<div id="content">

week-3/reading-list/script.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,30 @@ const books = [
2121
},
2222
];
2323

24+
const container = document.getElementById("reading-list");
25+
26+
function appendBook(book) {
27+
const liBook = document.createElement("li");
28+
29+
const description = document.createElement("p");
30+
description.textContent = book.title + " by " + book.author;
31+
32+
const alreadyRead = book.alreadyRead;
33+
const imgSrc = document.createElement("img");
34+
imgSrc.setAttribute("src", book.bookCoverImage);
35+
imgSrc.style.height = "400px";
36+
if (alreadyRead) {
37+
liBook.style.backgroundColor = "green";
38+
} else {
39+
liBook.style.backgroundColor = "red";
40+
}
41+
liBook.appendChild(description);
42+
43+
liBook.appendChild(imgSrc);
44+
45+
container.appendChild(liBook);
46+
}
47+
48+
for (let book of books) {
49+
appendBook(book);
50+
}

0 commit comments

Comments
 (0)