Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sprint-3/reading-list/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE >
<html lang="en_US">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand All @@ -13,3 +13,5 @@
<script src="script.js"></script>
</body>
</html>


22 changes: 22 additions & 0 deletions Sprint-3/reading-list/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const titleEl = document.querySelector("title");
titleEl.textContent = "Reading list app";
// for the tests, do not modify this array of books
const books = [
{
Expand All @@ -21,3 +23,23 @@ const books = [
},
];

function readingList(bookArray) {
const contentEl = document.getElementById("content");
const ulListEl = document.getElementById("reading-list");

for (const book of bookArray) {
const li = document.createElement("li");
ulListEl.appendChild(li);
li.textContent = `${book.title} by ${book.author}`;
const img = document.createElement("img");
li.appendChild(img);
img.src = book.bookCoverImage;

if (book.alreadyRead) {
li.style.backgroundColor = "green";
} else {
li.style.backgroundColor = "red";
}
}
}
readingList(books);
5 changes: 4 additions & 1 deletion Sprint-3/reading-list/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ body {
max-height: 40px;
width: auto;
}

li, img{
float: left;
position: relative;
}
.navbar-light .navbar-nav .nav-link {
color: #292b2c;
font-weight: 600;
Expand Down
Loading