Skip to content

London | May-2025 | Ikenna Agulobi | Data Groups | sprint 3 | Reading List #704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits 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
3 changes: 2 additions & 1 deletion Sprint-3/reading-list/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<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>
<h1>Reading list app</h1>
<div id="content">
<ul id="reading-list"></ul>
</div>
Expand Down
31 changes: 31 additions & 0 deletions Sprint-3/reading-list/script.js
Copy link

@day-lee day-lee Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you run the tests? There are two failing tests. Please take a look. Otherwise, everything else works as intended!

Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,34 @@ const books = [
},
];

function readingList(books) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename the function starting with verb, and describe the action more clearly?

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

for (let i = 0; i < books.length; i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you refactor a code to use forEach method with books array?

const li = document.createElement("li");
const bookDetails = document.createTextNode(
`${books[i].title} by ${books[i].author}`
);

li.classList.add("book-card");
li.appendChild(bookDetails);

if (books[i].alreadyRead) {
li.classList.add("read"); // If true, add the 'read' class
} else {
li.classList.add("not-read"); // If false, add the 'not-read' class
}
Comment on lines +36 to +40
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine, but this lines of code can be written in one line using a ternary operator. Can you refactor the code?


const bookImg = document.createElement("img");
bookImg.src = books[i].bookCoverImage;
bookImg.alt = `cover of ${books[i].title}`;
bookImg.style.width = "150px";

li.appendChild(document.createElement("br"));
li.appendChild(bookImg);

readingListUl.appendChild(li);
}
}

readingList(books);
27 changes: 27 additions & 0 deletions Sprint-3/reading-list/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,30 @@ body {
max-height: 80px;
}
}


/* css reading list app */
.book-card {
padding: 20px;
margin: 40px;
border-radius: 5px;
border: 1px solid rgb(153, 144, 144);
font-family:Arial, Helvetica, sans-serif;
}

h1{
text-align: center;
margin-top: 50px;
}

.read{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the colour for read class should be green to pass the test!

background-color: red;
}

.not-read{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the colour for not-read class should be red to pass the test! - check the reading-list.png for expected result.

background-color: green
}

.book-card img{
margin-top: 20px;
}