Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 2 | Book Library#457
Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 2 | Book Library#457mshayriyesaricicek wants to merge 5 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
Code is not properly indented, making it hard to read. Can you fix the Indention?
…itle, deleted unneccesary code
|
|
||
| render(); | ||
|
|
||
| this.reset(); |
There was a problem hiding this comment.
This seems quite advanced. Are you familiar with the meaning of this in JS?
In Piscine, you may be asked something like this:
- If you were not allowed to use
this, how would you rewritethis.reset()?
There was a problem hiding this comment.
If I couldn’t use this.reset(), I would manually reset each form field by setting their values back to empty. For example: document.getElementById("title").value = "";
document.getElementById("author").value = "";
document.getElementById("pages").value = "";
document.getElementById("check").checked = false;
There was a problem hiding this comment.
You can use any code as long as can explain the code when asked. In Piscine's interview, the interviewer may randomly pick a piece of code from your project and ask you to explain it.
| render(); | ||
| } | ||
|
|
||
| let newBook = new Book(title, author, pages, check); |
There was a problem hiding this comment.
Why do you choose to keep the pages as string? It is not wrong, just unusual.
| alert(`You've deleted title: ${myLibrary[i].title}`); | ||
| myLibrary.splice(i, 1); | ||
|
|
||
| saveLibrary(); | ||
|
|
||
| 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).
It’s better to display a confirmation message only after the associated operation has successfully completed.
Where should you place the alert() function call?
There was a problem hiding this comment.
When I load it up on live server and delete a book the delete message comes up after deleting the book not before but I have moved it to a more suitable position.
There was a problem hiding this comment.
alert() blocks execution of subsequent statements. To simulate the behavior, you can try this:
alert(`You've deleted title: ${myLibrary[i].title}`);
throw new Error("simulate something wrong happening ...");
myLibrary.splice(i, 1);
saveLibrary();
render();
The error will only throw after you close the alert dialog box.
|
Changes look good. |
|
Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it. |
Self checklist
Changelist
I made changes to make the drop down form work and upload the book details to the book list. I put an Enter button on the form. If all books are deleted it will automatically load up the preloaded books. If books are added it will save the information so it is available on reload. All information is in the correct place.