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
2 changes: 1 addition & 1 deletion Sprint-3/reading-list/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Title here</title>
<title>Reading List</title>
</head>
<body>
<div id="content">
Expand Down
28 changes: 28 additions & 0 deletions Sprint-3/reading-list/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,31 @@ const books = [
},
];

const list = document.getElementById("reading-list");

books.forEach((book) => {
const li = document.createElement("li");

// Add title + author (text must exist for tests)
li.textContent = `${book.title} by ${book.author}`;

// Create image
const img = document.createElement("img");
img.src = book.bookCoverImage;

// IMPORTANT: ensures exact HTML match for tests
img.setAttribute("src", book.bookCoverImage);

// Add image to list item
li.appendChild(img);

// Set background colour based on read status
if (book.alreadyRead) {
li.style.backgroundColor = "green";
} else {
li.style.backgroundColor = "red";
}

// Add to page
list.appendChild(li);
});
Loading