Skip to content

London | 26-ITP-May | Dipa Sarker | Sprint 2 | Book Library Project - #521

Open
Dipa-Sarker wants to merge 3 commits into
CodeYourFuture:mainfrom
Dipa-Sarker:debugging-book-library
Open

London | 26-ITP-May | Dipa Sarker | Sprint 2 | Book Library Project#521
Dipa-Sarker wants to merge 3 commits into
CodeYourFuture:mainfrom
Dipa-Sarker:debugging-book-library

Conversation

@Dipa-Sarker

Copy link
Copy Markdown

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

Changes made

  • Fixed bugs preventing books from being added correctly to the library.
  • Corrected book information handling, including title, author, and read status.
  • Improved the rendering of book cards on the page.
  • Added/fixed event handling for user interactions.
  • Debugged JavaScript issues using browser developer tools and verified the application behaviour.
    Testing
  • Tested adding new books through the form.
  • Confirmed that book details display correctly.
  • Verified that the read status updates properly.
  • Checked that the application works correctly in the browser using Live Server.

The changes were tested locally and the application is working as expected.

@Dipa-Sarker Dipa-Sarker added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 7, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

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/CodeYourFuture/Module-Data-Flows/blob/general-review-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 Aug 7, 2026
@Dipa-Sarker

Copy link
Copy Markdown
Author

Thank you for giving me the general feedback file. I made correction according to this.

@Dipa-Sarker Dipa-Sarker 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 Aug 9, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look solid. I just have a few suggestions.

Comment thread debugging/book-library/script.js Outdated
@@ -1,17 +1,18 @@
let myLibrary = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we declare myLibrary in a way that prevents it from being accidentally reassigned?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

we can use const instead of let.

Comment thread debugging/book-library/script.js Outdated
Comment on lines +24 to +28
const titleInput = document.getElementById("title"); //rename all variable names
const authorInput = document.getElementById("author");
const pagesInput = document.getElementById("pages");
const checkInput = document.getElementById("check");
const bookForm = document.getElementById("bookForm");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: Normal practice is to keep variable/constant declaration at beginning of the file (before function definition).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

okay, moved all the variables at the very beginning.

Comment thread debugging/book-library/script.js Outdated
Comment on lines +57 to +61
bookForm.addEventListener("submit", function (event) { //after user submits the book form
// this will run submit () function to add book
event.preventDefault();
submit();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Common practice is to keep all the "code that runs once on page load" in the same place (e.g., in a function named init() or setup()) and then call the function on page load.

Code that setups event listener usually fall into this category.

Comment thread debugging/book-library/script.js Outdated

changeBut.addEventListener("click", function () {
const changeButton = document.createElement("button"); //correct changeBut > changeButton
changeButton.id = i;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any need to assign an id attribute to this element?
In addition, "0", "1", ..., do not make good ID value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ok, we don't need button id, because we have event listener to response with change button. Besides, only id ="0", "1",...etc don't mean anything. I deleted this line.

Comment thread debugging/book-library/script.js Outdated
const deletedTitle = myLibrary[i].title; //save the book title which should have to delete
myLibrary.splice(i, 1);
render();
alert(`You've deleted title: ${deletedTitle}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

alert() is a blocking function call. As a result, invoking it prevents the browser from updating the UI until the dialog is dismissed.

If time permits, research for approaches that allows the UI to update before displaying the alert dialog. (This is an optional change).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok, I got your point. I did two things.

  1. Use confirm() before deleting.
  2. Put a normal message element in the HTML instead of using alert() after deletion.

@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 Aug 10, 2026
@Dipa-Sarker Dipa-Sarker 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 Aug 11, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look good. Well done.

Comment on lines +11 to +15
/*window.addEventListener("load", function () {
//delete e as it is never used
populateStorage();
render();
});
}); */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In practice, it is better to remove any unused code instead of wrap them in a comment in order to keep the code clean.

Comment on lines +120 to +122
const confirmed = confirm( //use confirm () to handle popup message for ok/cancel
`Are you sure you want to delete "${deletedTitle}"?`
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation is off.

@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 Aug 11, 2026
@Dipa-Sarker

Copy link
Copy Markdown
Author

Thank you for your feedback!

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants