-
-
Notifications
You must be signed in to change notification settings - Fork 158
London | 25-ITP-Sep| Shaghayegh Shirinfar | Sprint 2 | Book library #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
cjyuan
left a comment
There was a problem hiding this 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
Doing so can help me speed up the review process. Thanks.
|
Dear @cjyuan thank you for reviewing my code, I did some changes to my code. |
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks great so far! I only have a couple of small follow-ups.
debugging/book-library/script.js
Outdated
| const pages = pagesInput.value; | ||
|
|
||
| // FEEDBACK APPLIED: improved validation and normalization | ||
| if (!title || !author || !pages || Number(pages) <= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of numbers that should probably be treated as invalid page counts could pass this check.
Can you reject or post-process these numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks again for your feedback
I improved the page number check so it only lets real, positive whole numbers through. It now removes extra spaces, makes sure the value is actually a number, doesn’t allow decimals or negative numbers, and also blocks extremely large page counts.
debugging/book-library/script.js
Outdated
| clearForm(); | ||
|
|
||
| // Collapse form | ||
| $("#addForm").collapse("hide"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use mixed syntax in manipulating DOM? It is generally not commended for new project.
Note: Do you recognize what 3rd party dependency is needed in order for this statement to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you.
I replaced the jQuery collapse line with the Bootstrap 5 JavaScript API, so the form now closes using only plain JavaScript. This removes the jQuery dependency and keeps the code consistent with the rest of the project.
const collapse = bootstrap.Collapse.getOrCreateInstance(document.getElementById("addForm"));
collapse.hide();
debugging/book-library/script.js
Outdated
| $("#addForm").collapse("hide"); | ||
| } | ||
|
|
||
| addBtn.addEventListener("click", submitBook); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting the code on line 84 and the code on lines 28-29 (code that is executed once on page load) in one place could make it easier to understand what’s happening when the page loads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you . I moved all the code that runs when the page loads (loading the library, rendering the table, and setting up the add button) into one DOMContentLoaded block. This makes it easier to see what happens on page load.
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
| !Number.isInteger(pagesNum) || | ||
| pagesNum <= 0 || | ||
| pagesNum > 10000 || // reject unrealistic values | ||
| !isFinite(pagesNum) // rejects Infinity and NaN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the checks on line 67, 68, 71 are redundant. Can you figure out which?
Learners, PR Template
Self checklist
Changelist
I fixed the errors and fixed the add button.