West Midlands | 26-Jan-ITP | Fida Ali Zada | Sprint 2 | Book-Library#439
Open
alizada-dev wants to merge 8 commits intoCodeYourFuture:mainfrom
Open
West Midlands | 26-Jan-ITP | Fida Ali Zada | Sprint 2 | Book-Library#439alizada-dev wants to merge 8 commits intoCodeYourFuture:mainfrom
alizada-dev wants to merge 8 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Apr 16, 2026
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); |
Contributor
There was a problem hiding this comment.
-
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.valueis a string, and a number in scientific format may look unnatural as "number of pages".
Author
There was a problem hiding this comment.
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 on lines
+49
to
+52
| this.titleInput = title; | ||
| this.authorInput = author; | ||
| this.pagesInput = pages; | ||
| this.readCheckbox = check; |
Contributor
There was a problem hiding this comment.
These are the properties of a book. They are not DOM elements. The original names (except maybe check) are more natural.
Author
There was a problem hiding this comment.
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;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
Bugs that I fixed:
Please let me know of any more bugs (if yet to be fixed)