Glasgow | 26-ITP-Jan| Martin McLean |Sprint 2|Book Library#448
Glasgow | 26-ITP-Jan| Martin McLean |Sprint 2|Book Library#448mjm-git185 wants to merge 5 commits intoCodeYourFuture:mainfrom
Conversation
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.
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.
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?
There was a problem hiding this comment.
Thanks this site was very helpful
| @@ -1,100 +1,101 @@ | |||
| let myLibrary = []; | |||
There was a problem hiding this comment.
Safer to declare this using const.
| const titleInput = document.getElementById("title").value; | ||
| const authorInput = document.getElementById("author").value; | ||
| const pagesInput = document.getElementById("pages").value; | ||
| const checkInput = document.getElementById("check").checked; | ||
| if (titleInput == "" || pagesInput == "" || authorInput == "") { |
There was a problem hiding this comment.
-
.valueis a string. As such,pagesInputcould be a number in scientific format (e.g. "3e2"). -
What is an acceptable range of page count?
-
Should the app be accepting a string containing only spaces (e.g. " ") as the title or author of the book?
| return false; | ||
| return true; |
There was a problem hiding this comment.
Why return true when some of the input fields is empty?
| //clear the input values | ||
| } |
There was a problem hiding this comment.
What is this comment about?
| authorCell.innerHTML = myLibrary[i].author; | ||
| pagesCell.innerHTML = myLibrary[i].pages; | ||
|
|
||
| //deleteCell.innerHTML = button[i] |
There was a problem hiding this comment.
You should delete all unnecessary code instead of keeping them in a comment.
| myLibrary[i].check == true | ||
| ? (readStatus = "Yes") | ||
| : (readStatus = "No"); | ||
|
|
There was a problem hiding this comment.
Normally way to use ? : is:
readStatus = myLibrary[i].check ? "Yes" : "No";
condition ? v1 : v2is an expression. It evaluates tov1ifconditionis true, and tov2if conditionis false..checkis a boolean value. Comparing it totrueis optional.
| myLibrary[i].check == true | ||
| ? (myLibrary[i].check = false) | ||
| : (myLibrary[i].check = true); |
There was a problem hiding this comment.
This can be simplified into
myLibrary[i].check = !myLibrary[i].check;
| delBut.innerHTML = "Delete"; | ||
| delBut.addEventListener("clicks", function () { | ||
| const button = document.createElement("button"); | ||
| button.id = i; |
There was a problem hiding this comment.
- Lines 74, 94:
- Are the values assigned to these
idattributes unique? - Is there any need to assign an id attribute to either buttons?
- Are the values assigned to these
| alert(`You've deleted title: ${myLibrary[i].title}`); | ||
| myLibrary.splice(i, 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.
Changelist
I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
My changes meet the requirements of the task
I have tested my changes
My changes follow the style guide
my coursework