-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,34 @@ const books = [ | |
}, | ||
]; | ||
|
||
function readingList(books) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
background-color: green | ||
} | ||
|
||
.book-card img{ | ||
margin-top: 20px; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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!