-
-
Notifications
You must be signed in to change notification settings - Fork 125
Glasgow | May-2025 | Mansoor Munawar | Sprint 2 | Book library #320
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
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.
Most of the the suggestions in the feedback document I shared with you were not taken into consideration. Please go through the document thoroughly.
@@ -7,7 +7,7 @@ window.addEventListener("load", function (e) { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change one and not the other?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
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.
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.
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.
-
pagesInput.value
could 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Variable name is still not consistent
- Value assigned to the
id
attribute is not unique (when there are more than 5 books), and what is the use of theid
attribute in this application?
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.
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.