-
-
Notifications
You must be signed in to change notification settings - Fork 160
NW | 25-ITP-Sep | Ahmad Hmedan | Sprint 2 | Book Library #360
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?
NW | 25-ITP-Sep | Ahmad Hmedan | Sprint 2 | Book Library #360
Conversation
fix the wrong typo of variable name (delBtutton) and close brackets for if statement
cjyuan
left a comment
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.
Can you check if any of this general feedback can help you further improve your code?
https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md
Doing so can help me speed up the review process. Thanks.
…k and add id with event listener instead. Check validated
cjyuan
left a comment
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.
Good start.
debugging/book-library/script.js
Outdated
| const titleValue = titleInput.value.trim(); | ||
| const authorValue = authorInput.value.trim(); | ||
| const pagesValue = Number(pagesInput.value); | ||
| if (!titleValue || !authorValue || !pagesValue || pagesValue < 0) { |
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.
Some invalid "number of pages" could still pass this check.
| let readStatus = ""; | ||
| if (myLibrary[i].check == false) { | ||
| if (myLibrary[i].check === true) { | ||
| readStatus = "Yes"; | ||
| } else { | ||
| readStatus = "No"; | ||
| } | ||
| changeBut.innerText = readStatus; | ||
| changeReadBut.textContent = 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 81–87 as a single statement?
debugging/book-library/script.js
Outdated
| for (let i = 0; i < length; i++) { | ||
| let row = table.insertRow(1); | ||
| let titleCell = row.insertCell(0); | ||
| let row = tableBody.insertRow(); // why (1) not i+1 insert <tr> with four <td> |
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.
It is best practice to declare a variable using const when the variable is not going to be reassigned a value. There are several variables that has this characteristic.
debugging/book-library/script.js
Outdated
| deleteBut.className = "btn btn-warning"; | ||
| deleteBut.textContent = "Delete"; | ||
| deleteBut.addEventListener("click", function () { | ||
| const DeletedTitle = myLibrary[i].title; |
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.
The convention is to start a variable name with a lowercase letter in JS. Names that begin with an uppercase letter are for data type or class (e.g., Array, String, Book).
|
Thanks for the feedback, it is clear and helpful. |
debugging/book-library/script.js
Outdated
| const titleValue = titleInput.value.trim(); | ||
| const authorValue = authorInput.value.trim(); | ||
| const pagesValue = Number(pagesInput.value); | ||
| if (!titleValue || !authorValue || Number.isFinite(!pagesValue) || pagesValue <= 0) { |
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.
- "Number of pages" probably cannot be this kind of values but this check cannot yet reject these type of numbers.
| let readStatus = ""; | ||
| if (myLibrary[i].check == false) { | ||
| if (myLibrary[i].check === true) { | ||
| readStatus = "Yes"; | ||
| } else { | ||
| readStatus = "No"; | ||
| } | ||
| changeBut.innerText = readStatus; | ||
| readStatus= myLibrary[i].check===true? "yes":"no"; | ||
|
|
||
| changeReadBut.textContent = 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.
Some of the code here is redundant.
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.
There are still some variables that are assigned once declared using let.
cjyuan
left a comment
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.
Learners, PR Template
Self checklist
Changelist
I fix all bugs
Questions
none