Skip to content

West Midlands | 26-Jan-ITP | Fida Ali Zada | Sprint 2 | Book-Library#439

Open
alizada-dev wants to merge 8 commits intoCodeYourFuture:mainfrom
alizada-dev:book-library
Open

West Midlands | 26-Jan-ITP | Fida Ali Zada | Sprint 2 | Book-Library#439
alizada-dev wants to merge 8 commits intoCodeYourFuture:mainfrom
alizada-dev:book-library

Conversation

@alizada-dev
Copy link
Copy Markdown

@alizada-dev alizada-dev commented Apr 14, 2026

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

Bugs that I fixed:

  • Website loads and shows the books in my library
  • Error in console fixed
  • It uses the appropriate title name and the author name
  • The delete button works now
  • When a book that I say I've read is added, it saves the right answer
  • The form inputs clear after a book is added

Please let me know of any more bugs (if yet to be fixed)

@alizada-dev alizada-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 14, 2026
Comment thread debugging/book-library/script.js Outdated
Comment on lines +31 to +38
!titleInput.value.trim() ||
!authorInput.value.trim() ||
!pagesInput.value.trim()
) {
alert("Please fill all fields!");
return false;
} else {
let book = new Book(title.value, title.value, pages.value, check.checked);
library.push(book);
let book = new Book(titleInput.value, authorInput.value, pagesInput.value, readCheckbox.checked);
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.

  • You checked the trimmed value but you are using the untrimmed values. A better approach is to first store the preprocessed input in variables, then use those cleaned values consistently throughout the rest of the code.

  • pagesInput.value is a string, and a number in scientific format may look unnatural as "number of pages".

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.

Got it, sir. Thank you for this out. Could you check if it is okay this time?

function submit() {
  const trimmedTitle = titleInput.value.trim();
  const trimmedAuthor = authorInput.value.trim();
  const trimmedPages = +pagesInput.value.trim();

  if (
    !trimmedTitle ||
    !trimmedAuthor ||
    !trimmedPages
  ) {
    alert("Please fill all fields!");
    return false;
  } else {
    let book = new Book(trimmedTitle, trimmedAuthor, trimmedPages, readCheckbox.checked);
    myLibrary.push(book);

    titleInput.value = "";
    authorInput.value = "";
    pagesInput.value = "";
    readCheckbox.checked = false;
    render();
  }
}

Comment thread debugging/book-library/script.js Outdated
Comment on lines +49 to +52
this.titleInput = title;
this.authorInput = author;
this.pagesInput = pages;
this.readCheckbox = check;
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.

These are the properties of a book. They are not DOM elements. The original names (except maybe check) are more natural.

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.

You are absolutely right.

function Book(title, author, pages, check) {
  this.title = title;
  this.author = author;
  this.pages = pages;
  this.check = check;
}
  titleCell.textContent = myLibrary[i].title;
   authorCell.textContent = myLibrary[i].author;
   pagesCell.textContent = myLibrary[i].pages;

@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 Apr 16, 2026
@alizada-dev alizada-dev 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 Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants