London | 26-ITP-May | Edina Kurdi | Sprint 2 | Book Library - #552
London | 26-ITP-May | Edina Kurdi | Sprint 2 | Book Library#552edinakurdi wants to merge 36 commits into
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Could you also check if any of this general feedback can help you further improve your code?
https://github.com/CodeYourFuture/Module-Data-Flows/blob/general-review-feedback/debugging/book-library/feedback.md
Doing so can help me speed up the review process. Thanks.
| <label class="form-check-label"> | ||
| <input type="checkbox" class="form-check-input" id="check" value="" />Read | ||
| </label> |
There was a problem hiding this comment.
If this checkbox is not showing, could you try fixing the issue with the help of AI. The issue is related to Bootstrap 4.4.1. So mentioning "Bootstrap 4.4.1" to AI might help.
| <label class="form-check-label"> | ||
| <input type="checkbox" class="form-check-input" id="check" value="" />Read | ||
| </label> | ||
| <input type="submit" value="Submit" class="btn btn-primary" onclick="submit();" /> |
There was a problem hiding this comment.
Could you look up the trade-off between
- attaching event listener in HTML
- attaching event listener in JS using
.addEventListener()?
There was a problem hiding this comment.
inline breaks separation of concersn and doesnt allow multiple event listeneres, and forces the function to global scope which can cause issues, but it is quick to write, shorter
addEventListener supports multiple event listeners, no global scope, but requires more code.
updated
condense pushing the books to the library into a single statement
-clear book-table-body with innerHTML -append rows in order -replace innerHTML with textContent for title, author, pand ages
-rename buttons to toggleReadBtn and deleteBtn, -use textContent for button text, -add confirm() to check if user wants to delete a book
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good.
Well done.
| let book = new Book(title.value, title.value, pages.value, check.checked); | ||
| library.push(book); | ||
| render(); | ||
| bookForm.addEventListener("submit", function (e) { |
There was a problem hiding this comment.
Could consider placing all code that runs once on page load in a single function. For example, you could put it inside the page load callback or create a function named init() or setup() and call it once when the page loads.
This makes it easier to locate and manage all the code that runs once when the app starts.
| const confirmDel = confirm( | ||
| `Are you sure you want to delete "${myLibrary[i].title}"?` | ||
| ); | ||
| if (confirmDel) { | ||
| myLibrary.splice(i, 1); | ||
| render(); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Informing the user that the book has been deleted is not quite the same as asking whether they want to delete the book though.
Learners, PR Template
Self checklist
Changelist
Other corrections I made:
Added missing author form validation, fixed HTML input types, corrected a book title typo, and removed redundant CSS.