-
-
Notifications
You must be signed in to change notification settings - Fork 125
LONDON | MAY2025 |FATMA_DEGIRMENCI | SPRINT2 | BOOK_LIBRARY #292
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
…sistent using localStorage
Can you check if any of this general feedback can help you further improve your code? Doing so can help me speed up the review process. Thanks. |
… .value usage removed
I tried to improve and adjust my code according to the feedback. Thank you. |
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. I have few more suggestions.
debugging/book-library/script.js
Outdated
loadLibrary(); | ||
if(myLibrary.length===0){ | ||
populateStorage(); | ||
|
||
} |
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.
Indentation is off.
debugging/book-library/script.js
Outdated
titleInput.value = ""; | ||
authorInput.value = ""; | ||
pagesInput.value = ""; | ||
checkInput.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.
Could also consider using .reset()
method of a form element.
debugging/book-library/script.js
Outdated
function protectMyLibrary(){ | ||
localStorage.setItem("myLibrary" , JSON.stringify(myLibrary)); | ||
} |
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.
May I suggest naming the function saveLibrary
? Since “save” and “load” are usually paired, this would make the naming more consistent.
debugging/book-library/script.js
Outdated
function loadLibrary() { | ||
const storedLibrary = localStorage.getItem("myLibrary"); | ||
if (storedLibrary) { | ||
myLibrary = JSON.parse(storedLibrary); |
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.
When a book is added to the array in submit()
and populateStorage()
, the code adds an instance of Book to the array.
On line 63, only the key–value pairs of the object are stored in the JSON-formatted string; the “prototype chain” of the Book object is not preserved. On line 69, the restored array therefore contains only plain objects, not Book instances.
In this app, it happens that a plain object works just as well as a Book instance.
In general, however, a more appropriate approach is to add code that converts the restored array into an array of Book instances.
…unctions for clarity,
Changes look good! Well done! |
Self checklist