Skip to content

Conversation

@TzeMingHo
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

I have debugged the book library, which now populates the book collection, displays book information correctly, adds books, and deletes books.

@TzeMingHo TzeMingHo added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 3, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Nov 12, 2025

Can you check if any of this general feedback can help you further improve your code?
https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md

Doing so can help me speed up the review process. Thanks.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 12, 2025
@TzeMingHo
Copy link
Author

Can you check if any of this general feedback can help you further improve your code? https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md

Doing so can help me speed up the review process. Thanks.

Thank you CJ,

The feedback document is very benefitical. I didn't notice that the project I sumbited still got so many bugs. Thank you for letting me know. I have made some improvements.

@TzeMingHo TzeMingHo added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 12, 2025
@A-O-Emmanuel A-O-Emmanuel added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 12, 2025
Copy link

@A-O-Emmanuel A-O-Emmanuel left a comment

Choose a reason for hiding this comment

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

Your book library works, I just used it and it seems okay, @cjyuan do you have any other comments so that I can mark it complete, thanks

@A-O-Emmanuel A-O-Emmanuel added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Nov 12, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Code works. I just have a few suggestions.


<div id="demo" class="collapse">
<div class="form-group">
<form class="form-group" id="book-form" onsubmit="handleSubmit(event)" >
Copy link
Contributor

Choose a reason for hiding this comment

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

Could consider attaching event handler to the form in JS (to keep HTML code free of JS code)

Copy link
Author

Choose a reason for hiding this comment

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

Yes. I have removed the function from the HTML and created an eventListener in the script.

pages.value == ""
!titleInput.value.trim() ||
!authorInput.value.trim() ||
pagesInput.value <= 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Some "weird" numbers (that shouldn't be considered valid page count) could still pass this check. Can you figure out what these numbers are and "handle" them appropriately?

Copy link
Author

Choose a reason for hiding this comment

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

I tried my best to think of the weird numbers could be some spaces before or after the actual numbers. I added a trim process for the pages value as well. I hope this will help prevent some strange situations.

} else {
let book = new Book(title.value, title.value, pages.value, check.checked);
library.push(book);
let book = new Book(String(titleInput.value), String(authorInput.value), Number(pagesInput.value), checkInput.checked);
Copy link
Contributor

Choose a reason for hiding this comment

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

.value is always a string. And on line 39, they could still contain leading or trailing spaces.

for (let n = rowsNumber - 1; n > 0; n-- {
table.deleteRow(n);
}
let tableBody = document.getElementById("display-body")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could consider (in code refactoring stage) change let to const for all variables that are not going to be reassigned a value.

@TzeMingHo TzeMingHo added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 13, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Changes look great!

Comment on lines 33 to 38
let pagesValue = Number(pagesInput.value.trim());
let read = checkInput.checked;
if (
!titleInput.value.trim() ||
!authorInput.value.trim() ||
pagesInput.value <= 0
!titleValue||
!authorValue ||
!Number.isInteger(pagesValue) ||
Copy link
Contributor

@cjyuan cjyuan Nov 13, 2025

Choose a reason for hiding this comment

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

Trim of pagesinput.value is optional but ensuring pagesValue is an integer would prevent "weird" page count. So, well done!

Comment on lines +51 to +53
const bookForm = document.getElementById("book-form")
bookForm.addEventListener("submit", (event) => handleSubmit(event));

Copy link
Contributor

@cjyuan cjyuan Nov 13, 2025

Choose a reason for hiding this comment

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

It is better to group code that is to be executed once (line 52) in one place (to make locating them easier). For example, in the window.onload callback function (lines 3-5).

</table>

<script src="script.js"></script>
<script src="script.js" defer></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Consider loading script.js as an ES module to isolate its scope from the global context:

<script src="script.js" type="module"></script>

This ensures that variables, functions, and imports in script.js don’t leak into the global namespace, helps prevent naming conflicts, and enables the use of modern JavaScript features like import and export.

  • Also, with type="module", defer is automatically enforced.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you. It is something useful. Good to know.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants