-
-
Notifications
You must be signed in to change notification settings - Fork 155
LONDON | 25-ITP-MAY | TEWODROS BEKERE | SPRINT-3 | Reading-List-App #732
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 |
---|---|---|
|
@@ -4,11 +4,13 @@ | |
<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"> | ||
<ul id="reading-list"></ul> | ||
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. Hint: You will need to use this id 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. Fixed. 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. I can't see the changed files and new commits! |
||
|
||
<ul id="reading-list-app"></ul> | ||
|
||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,29 @@ const books = [ | |
}, | ||
]; | ||
|
||
function readingListApp(books) { | ||
const container = document.getElementById("reading-list-app"); | ||
if (!container) return; | ||
|
||
for (let i = 0; i < books.length; i++) { | ||
const book = books[i]; | ||
|
||
const bookItem = document.createElement("div"); | ||
bookItem.className = "book"; | ||
bookItem.style.backgroundColor = book.alreadyRead ? "green" : "red"; | ||
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 it's best to keep styles in the css file rather then modifying in the DOM. I would recommend using class to change the colour. Can you refactor the code accordingly? 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. Fixed. |
||
|
||
const bookInfo = document.createElement("div"); | ||
bookInfo.innerHTML = `<strong>${book.title}</strong> by <strong>${book.author}</strong>`; | ||
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. innerHTML has a potential security issue. It's better to avoid using it. FYI, find more in this link. Can you refactor the code with an alternative property? 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. Fixed. |
||
|
||
const img = document.createElement("img"); | ||
img.src = book.bookCoverImage; | ||
img.alt = `${book.title} cover`; | ||
|
||
bookItem.appendChild(bookInfo); | ||
|
||
bookItem.appendChild(img); | ||
container.appendChild(bookItem); | ||
} | ||
} | ||
|
||
readingListApp(books); |
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 test? All tests fails at the moment. Please refactor the code accordingly!