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
6 changes: 3 additions & 3 deletions Sprint-3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"devDependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/user-event": "^14.6.1",
"jest": "^30.0.4",
"jest-environment-jsdom": "^30.0.4"
"@testing-library/user-event": "^13.5.0",
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.0.0"
}
}
6 changes: 3 additions & 3 deletions Sprint-3/reading-list/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE >
<html lang="en_US">
<!DOCTYPE html>
<html lang="en">
<head>
<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
33 changes: 33 additions & 0 deletions Sprint-3/reading-list/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,36 @@ const books = [
},
];

// reading list code

// 1. find the <ul> element
const readingList = document.getElementById("reading-list");

// 2. loop through each book
books.forEach((book) => {
// 3. create elements
const li = document.createElement("li");
const h2 = document.createElement("h2");
const p = document.createElement("p");
const img = document.createElement("img");

// 4. set content
h2.textContent = book.title;
p.textContent = book.author;
img.src = book.bookCoverImage;

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

// 6. append elements to <li>
li.appendChild(h2);
li.appendChild(p);
li.appendChild(img);

// 7. append li to ul
readingList.appendChild(li);
});