Glasgow | May-2025 | Mansoor Munawar | Sprint 2 | Book library#320
Glasgow | May-2025 | Mansoor Munawar | Sprint 2 | Book library#320MansoorM11 wants to merge 11 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Most of the the suggestions in the feedback document I shared with you were not taken into consideration. Please go through the document thoroughly.
| function populateStorage() { | ||
| if (myLibrary.length == 0) { | ||
| let book1 = new Book("Robison Crusoe", "Daniel Defoe", "252", true); | ||
| let book1 = new Book("Robison Crusoe", "Daniel Defoe", 252, true); |
There was a problem hiding this comment.
Why change one and not the other?
There was a problem hiding this comment.
i totally missed that. Thanks for letting me know
debugging/book-library/script.js
Outdated
| let readStatus = ""; | ||
| if (myLibrary[i].check == false) { | ||
| readStatus = "Yes"; | ||
| } else { | ||
| readStatus = "No"; | ||
| } else { | ||
| readStatus = "Yes"; | ||
| } | ||
| changeBut.innerText = readStatus; |
There was a problem hiding this comment.
This could be a good opportunity to practice using the ? : conditional operator. Can you rewrite the code on lines 77-83 as a single statement?
cjyuan
left a comment
There was a problem hiding this comment.
According to https://validator.w3.org/, there are errors in your index.html. Can you fix these errors?
debugging/book-library/script.js
Outdated
| !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); | ||
| myLibrary.push( | ||
| new Book( | ||
| titleInput.value.trim(), | ||
| authorInput.value.trim(), | ||
| Number(pagesInput.value), | ||
| checkInput.checked | ||
| ) | ||
| ); |
There was a problem hiding this comment.
-
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.
-
pagesInput.valuecould be a value like "3.1416".
debugging/book-library/script.js
Outdated
| let deleteBtn = document.createElement("button"); | ||
| deleteBtn.id = i + 5; |
There was a problem hiding this comment.
- Variable name is still not consistent
- Value assigned to the
idattribute is not unique (when there are more than 5 books), and what is the use of theidattribute in this application?
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good. Well done.
Self checklist
Briefly explain your PR.
fixed the bugs in book library and refactor code to meet the requirements of the task. And also used "https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md" to improve my code
Questions
Ask any questions you have for your reviewer.