Skip to content

Conversation

@enjoy15
Copy link

@enjoy15 enjoy15 commented Nov 29, 2025

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

  • Debug Book Library Project

@enjoy15 enjoy15 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. Module-Data-Flows The name of the module. labels Nov 29, 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.

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

@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 30, 2025
@enjoy15
Copy link
Author

enjoy15 commented Dec 1, 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

Update index.html and script.js as per feedbacks.

@enjoy15 enjoy15 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 1, 2025
@wankoak wankoak removed the Reviewed Volunteer to add when completing a review with trainee action still to take. label Dec 1, 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.

authorCell.innerHTML = myLibrary[i].author;
pagesCell.innerHTML = myLibrary[i].pages;
const table = document.getElementById("display");
table.innerHTML = "<tr><th>Title</th><th>Author</th><th>Pages</th><th>Read</th><th>Actions</th></tr>";
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also just clear <tbody>.

Note: There was a <tbody> in the original HTML code.

Comment on lines +57 to +66
myLibrary.forEach((book, index) => {
const row = table.insertRow();
row.innerHTML = `
<td>${book.title}</td>
<td>${book.author}</td>
<td>${book.pages}</td>
<td><button class="btn btn-success toggle-read" data-index="${index}">${book.check ? "Yes" : "No"}</button></td>
<td><button class="btn btn-warning delete-book" data-index="${index}">Delete</button></td>
`;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

If title and author contain special characters such as '<' and '&' they could messed up the HTML output.

const index = e.target.dataset.index;
myLibrary.splice(index, 1);
render();
alert("Book deleted successfully.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently when the alert dialog box appears, the UI is still showing the deleted item. The UI is only updated after the user closes the dialog box.

Can you figure out how to make the alert dialog box appear only after the UI is updated?

Notes:

  • This change is optional.
  • In practice, it might not be a good idea to use alert() to show any message.

@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 Dec 1, 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. Module-Data-Flows The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants