Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 2 | Book Library - #450
Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 2 | Book Library#450mahmoudshaabo1984 wants to merge 3 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
|
Hi @cifarquhar — PR #450 is ready for review. I have fixed all 5 bugs listed in the readme.md file. The app now loads correctly, books can be added and deleted, and the read status toggles as expected. Please let me know if anything needs to be changed. Thank you! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
You have fixed all the bugs, but there are still plenty of room you can improve the code.
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.
|
Hi CJ, Thank you for your feedback. I have reviewed your comments and applied the following improvements: script.js
index.html
Please let me know if there is anything else to improve. Thank you, |
| titleInput.value === "" || | ||
| authorInput.value === "" || | ||
| pagesInput.value === "" |
There was a problem hiding this comment.
-
String input may contain only space characters or leading/trailing space. Ideally the app should not accept a string containing only spaces as a book title or author's name.
-
pageInput.valueis a string and it can be a number in scientific format (e.g. "3e2") -- which may look weird when displayed as a value of page count.
A better and safer approach to deal with user input is to first preprocess/sanitise them, and then store the cleaned values in variables. Thereafter, refer only to the variables for cleaned values consistently throughout the rest of the code.
|
Hi CJ, Thank you for the detailed second round of feedback. I have applied all of your suggestions:
Please let me know if there is anything else to improve. Thank you, |
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good. Well done.
| alert(`"${myLibrary[index].title}" has been deleted.`); | ||
| myLibrary.splice(index, 1); | ||
| render(); |
There was a problem hiding this comment.
The alert message is shown before the book is actually deleted; the deletion only occurs after the alert dialog is dismissed. This introduces a risk that the operation may not complete (e.g., if the user closes the browser before dismissing the alert).
In general, it’s better to display a confirmation message only after the associated operation has successfully completed.
| if (trimmed.toLowerCase().includes("e")) { | ||
| return NaN; | ||
| } |
There was a problem hiding this comment.
Can also just let Number() convert the input even if it contains an 'e' -- less code to maintain.
|
Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it. |
What bugs did I fix?
Bug 1 - Website loads but doesn't show any books
The
forloop in therenderfunction was missing a closing parenthesis)before the{. This caused a syntax error that stopped all JavaScript from running.Bug 2 - Error in console when you try to add a book
The
submitfunction was callinglibrary.push(book)but the array is namedmyLibrary. Fixed by using the correct variable name. Also added validation for the author field.Bug 3 - It uses the title name as the author name
In the
submitfunction,title.valuewas used twice. The second argument should beauthor.value.Bug 4 - Delete button is broken
The delete button variable was created as
delButtonbut then referenced asdelButthree times. Also the event name was"clicks"instead of"click". Fixed both issues.Bug 5 - Read status saves the wrong answer
The
ifcondition was inverted.check == falsewas showing "Yes". Fixed socheck == truecorrectly shows "Yes".How to test
index.htmlin the browserHi @cifarquhar — I have fixed all 5 bugs listed in the readme. Please let me know if you have any feedback. Thank you!