London | 26-ITP-May | Zadri Abdule | Sprint 2 | Book - library - #520
London | 26-ITP-May | Zadri Abdule | Sprint 2 | Book - library#520Zadri415 wants to merge 9 commits into
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Changes look good.
There are a few improvements you could still make.
| #toast { | ||
| position: fixed; |
There was a problem hiding this comment.
Why not prepare the CSS in style.css?
| /> | ||
| <div class="col"> | ||
| <label for="pages">Pages:</label> | ||
| <input type="number" class="form-control" id="pages" name="pages" min="1" required /> |
There was a problem hiding this comment.
Could you find out why the browser is not enforcing the constraint min="1" required? Currently a user could submit page count suchas-123and12.345`.
| // Preprocessing / validation: | ||
| // - reject empty or whitespace-only title/author (checked AFTER trim, not before) | ||
| // - reject non-numeric or non-positive page counts | ||
| if (!title || !author || !pagesRaw || !Number.isFinite(pages) || pages <= 0) { |
There was a problem hiding this comment.
-
Do you know why checking
!pageRawis optional? -
What type of number should a page count be?
| titleInput.value = ""; | ||
| authorInput.value = ""; | ||
| pagesInput.value = ""; | ||
| checkInput.checked = false; |
There was a problem hiding this comment.
If the input elements are inside a <form>, we could also just reset the form with one function call.
| const table = document.getElementById("display"); | ||
| const tbody = table.getElementsByTagName("tbody")[0]; |
There was a problem hiding this comment.
Note: We could also use document.querySelector() to select the specific tbody element directly.
| const idx = myLibrary.indexOf(book); | ||
| if (idx === -1) return; |
There was a problem hiding this comment.
We could also obtain the index of the current book from the second parameter of the function pass to forEach() on line 66.
There was a problem hiding this comment.
Thank you for the feedback. I have updated both files.
|
May I know why you closed this PR? |
|
Had issues with the branch not pushing some of recent commits. here's the
other PR: #564
…On Mon, Aug 17, 2026 at 9:10 PM CJ Yuan ***@***.***> wrote:
*cjyuan* left a comment (CodeYourFuture/Module-Data-Flows#520)
<#520 (comment)>
May I know why you closed this PR?
—
Reply to this email directly, view it on GitHub
<#520?email_source=notifications&email_token=BOUYTCQBPTFWEDZVLUCFDDL5KNRDDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMZRHE3DSMRRGQ42M4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5319692149>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BOUYTCT2JUCUW2UBOG4PC335KNRDDAVCNFSNUABFKJSXA33TNF2G64TZHM3TSOJSGQ2TQMRXHNEXG43VMU5TKMBYGM2TSOBYGQ22C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/BOUYTCWRSTX6RTQXGOPHBCT5KNRDDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMZRHE3DSMRRGQ42M4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/BOUYTCQNWGUVZZTTGAKS4LL5KNRDDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMZRHE3DSMRRGQ42M4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The validation boot does not recognise duplicated PRs for any backlog in ITP. Currently you have two book library PRs. If you want to continue to work on this PR, you would need to close the other PR first. Otherwise the validation bot will reject this PR. |
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good.
There are some improvements you could still make though.
| // Native "required"/"min"/"step" already ran before this handler fires | ||
| // (see bookForm's submit listener below), so this is a second layer | ||
| // for things HTML attributes can't express, like whitespace-only text. | ||
| if (!title || !author || !pagesRaw || !Number.isFinite(pages) || pages <= 0) { |
There was a problem hiding this comment.
-
Do you know why checking
!pageRawis optional? -
Why not just check if
pagesis a whole number?
| bookForm.addEventListener("submit", (event) => { | ||
| event.preventDefault(); | ||
| addBook(); | ||
| }); | ||
|
|
||
| document.addEventListener("DOMContentLoaded", () => { | ||
| populateStorage(); | ||
| render(); | ||
| }); |
There was a problem hiding this comment.
Good job in placing all code that runs once on page load at the end of the file. Doing so could make locating and managing them easier.
A better practice would be to keep them in a single function. For example, you could put it inside the page load callback or create a function named init() or setup() and call it once when the page loads.
Learners, PR Template
Self checklist
Changelist
Questions
N/A