NW | 25-ITP-Sep | Ahmad Hmedan | Sprint 2 | Book Library#360
NW | 25-ITP-Sep | Ahmad Hmedan | Sprint 2 | Book Library#360AhmadHmedann wants to merge 19 commits intoCodeYourFuture:mainfrom
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.
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
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.
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.
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.
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.
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.
- "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.
Some of the code here is redundant.
There was a problem hiding this comment.
There are still some variables that are assigned once declared using let.
Learners, PR Template
Self checklist
Changelist
I fix all bugs
Questions
none