-
-
Notifications
You must be signed in to change notification settings - Fork 120
ZA | 25-ITP-May | Malusi Skunyana | Data Flows | Book Library #296
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
…ubmit() call to addBook(), remove placeholder table row
…r() loop syntax, repair delete button event, correct read status logic, rename submit() to addBook(), clear form after add
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 change the base branch of this PR from CYF's
book-library
to CYF'smain
?

- 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.
…ags of void elements
…numbers, add input validation, improve button naming, and fix delete confirmation timing
@cjyuan, I have changed the base branch to CYF's main. I have also made improvements to my code as per the general feedback you referred me to. Thank you so much for the great feedback. |
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.
Changes look good. Well done.
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); | ||
render(); | ||
return; | ||
} | ||
|
||
if (!Number.isInteger(Number(pagesInput.value)) || Number(pagesInput.value) <= 0) { | ||
alert("Pages must be a positive number."); | ||
return; | ||
} | ||
|
||
let book = new Book( | ||
titleInput.value.trim(), | ||
authorInput.value.trim(), | ||
Number(pagesInput.value), |
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.
For better performance (reduce number of function calls) and reducing the chance of using raw input accidently, we could stored the pre-processed/sanitized/normalized input in some variables first, and reference the variables in other part of the function.
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, CJ. I really appreciate the great feedback.
function clearForm() { | ||
titleInput.value = ""; | ||
authorInput.value = ""; | ||
pagesInput.value = ""; | ||
readCheckbox.checked = false; | ||
} |
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.
If the input elements are enclosed inside a <form>
, we could also clear them by calling the .reset()
method of the form element.
Learners, PR Template
Self checklist
Changelist
Summary
This PR fixes all known bugs in the Book Library project so it meets the specified requirements:
Changes by File
index.html:
script.js:
Questions
Ask any questions you have for your reviewer.