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

Commit 0ce9cfa

Browse files
committed
Written function and update css
1 parent 08f06b2 commit 0ce9cfa

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

week-3/reading-list/script.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
function readingList(books) {
2+
const readingList = document.getElementById("reading-list");
3+
4+
for (const item of books) {
5+
const list = document.createElement("li");
6+
7+
list.setAttribute("class", item.alreadyRead ? "teal" : "red");
8+
9+
const p = document.createElement("p");
10+
p.innerText = `${item.title} by ${item.author}`;
11+
12+
readingList.appendChild(list);
13+
list.appendChild(p);
14+
15+
const image = document.createElement("img");
16+
image.src = item.bookCoverImage;
17+
list.appendChild(image);
18+
}
19+
}
20+
121
// for the tests, do not modify this array of books
222
const books = [
323
{
@@ -21,3 +41,4 @@ const books = [
2141
},
2242
];
2343

44+
readingList(books);

week-3/reading-list/style.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ body {
121121
}
122122

123123
.red {
124-
background-color: red;
124+
background-color: orangered;
125+
}
126+
127+
.teal {
128+
background-color: teal;
125129
}
126130

127131
.addArticle {

0 commit comments

Comments
 (0)