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

NW6 | Fikret Ellek | JS2 Module | [TECH ED] Reading list | Week 3 #210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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 week-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 app</title>
</head>
<body>
<div id="content">
Expand Down
27 changes: 27 additions & 0 deletions week-3/reading-list/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,30 @@ const books = [
},
];

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

function appendBook(book) {
const liBook = document.createElement("li");

const description = document.createElement("p");
description.textContent = book.title + " by " + book.author;

const alreadyRead = book.alreadyRead;
const imgSrc = document.createElement("img");
imgSrc.setAttribute("src", book.bookCoverImage);
imgSrc.style.height = "400px";
if (alreadyRead) {
liBook.style.backgroundColor = "green";
} else {
liBook.style.backgroundColor = "red";
}
liBook.appendChild(description);

liBook.appendChild(imgSrc);

container.appendChild(liBook);
}

for (let book of books) {
appendBook(book);
}