Skip to content

Conversation

@HoussamLh
Copy link

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

## Changelist

  1. Fixed issue where books did not display on page load

  2. Corrected bug where title was being used as author when adding new books

  3. Fixed delete button (wrong variable name + wrong event type)

  4. Corrected read/unread toggle so it shows the correct value

  5. Cleaned up table rendering loop to properly remove old rows

  6. Minor syntax corrections (missing bracket in for loop)

## Questions

  1. Is my render() function written in a clean way, or should I break it into smaller functions?

  2. Would you recommend converting the Book constructor into a class for better readability?

HoussamLh and others added 2 commits August 18, 2025 16:17
- change library.push(book) to myLibrary.push(book).
-  add a ) to the end of the for loop condition to avoid syntax error.
- change myLibrary[i].check to myLibrary[i].check == true to check if the book is read or not.
- change delBut to delButton because we declare it.
- The event listener is "clicks" instead of "click".
@HoussamLh HoussamLh added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 18, 2025
@sambabib sambabib 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 Aug 18, 2025
let book = new Book(title.value, title.value, pages.value, check.checked);
library.push(book);
//fix: change title.value to author.value
let book = new Book(title.value, author.value, pages.value, check.checked);

Choose a reason for hiding this comment

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

This is nicely done.

for (let n = rowsNumber - 1; n > 0; n-- {
// Fix : add a ) to the end of the for loop condition
// to avoid syntax error.
for (let n = rowsNumber - 1; n > 0; n--) {

Choose a reason for hiding this comment

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

Good catch of the syntax error here as well.

//add and wait for action for read/unread button
let changeBut = document.createElement("button");
changeBut.id = i;
changeBut.className = "btn btn-success";

Choose a reason for hiding this comment

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

Whilst this isn’t a bad variable name, it is good practice to have clear variable names so the purpose can be inferred at a quick glance. For example, changeButton would have been better here. Something to note moving forward.

// Fix: change myLibrary[i].check to myLibrary[i].check == true
// to check if the book is read or not.
if (myLibrary[i].check == true) {
readStatus = "Yes";

Choose a reason for hiding this comment

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

When you build applications with status updates, it is good practice to store these statuses in variables/objects. For a small application like this, it is not necessary but as your codebase grows bigger, it becomes easier to slot in the status variable than constantly type in a string (typos could happen). This is something to note.

delBut.className = "btn btn-warning";
delBut.innerHTML = "Delete";
delBut.addEventListener("clicks", function () {
delButton.id = i + 5;

Choose a reason for hiding this comment

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

See. You used a better variable name here, so try to keep it consistent.

@sambabib sambabib added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 19, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants