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

NW6 | Hadika Malik | Module JS2 | Week 3 | Reading list #216

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 13 additions & 1 deletion week-3/reading-list/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<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 All @@ -13,3 +14,14 @@
<script src="script.js"></script>
</body>
</html>


<!-- <div id="content">
<ul id="reading-list">
<li id="list-of-books">
<p>book title</p>
HadikaMalik marked this conversation as resolved.
Show resolved Hide resolved
<p>book author</p>
<img <p>books cover img url</p> />
</li>
</ul>
</div> -->
21 changes: 21 additions & 0 deletions week-3/reading-list/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// for the tests, do not modify this array of books
const books = [
{
Expand All @@ -21,3 +22,23 @@ const books = [
},
];


const getReadingList = document.getElementById("content");
const listOfBooks = document.getElementById("reading-list");
console.log(getReadingList);
HadikaMalik marked this conversation as resolved.
Show resolved Hide resolved

for (const item of books){
const li = document.createElement("li");
listOfBooks.appendChild(li);

const p = document.createElement("p");
li.appendChild(p);
p.textContent = `${item.title} by ${item.author}`;

const image = document.createElement("img");
li.appendChild(image);
image.src = item.bookCoverImage;

if (item.alreadyRead === true){li.setAttribute("class", "green")}
else {li.setAttribute("class", "red")}
HadikaMalik marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions week-3/reading-list/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ body {
background-color: red;
}

.green{
background-color: green;
}

.addArticle {
margin-bottom: 10px;
}
Expand Down