Manchester| 25-ITP-SEP| Fithi Teklom| Sprint 2 | Book Library#361
Manchester| 25-ITP-SEP| Fithi Teklom| Sprint 2 | Book Library#361Fithi-Teklom wants to merge 11 commits intoCodeYourFuture:mainfrom
Conversation
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
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.
debugging/book-library/script.js
Outdated
| if (!title.value.trim() || !author.value.trim() || !pages.value.trim()) { | ||
| alert("Please fill all fields!"); | ||
| return false; | ||
| } |
debugging/book-library/script.js
Outdated
| library.push(book); | ||
| render(); | ||
| } | ||
| let book = new Book(title.value.trim(), author.value.trim(), pagesNumber, check.checked); |
There was a problem hiding this comment.
-
Could consider saving preprocessed and sanitised input in some variables first to
- improve performance
- to avoid accidently using raw input later
-
Not all integers are valid number of pages.
| let pagesCell = row.insertCell(2); | ||
| let wasReadCell = row.insertCell(3); |
There was a problem hiding this comment.
If a variable is not going to be reassigned a value, it is best practice to declare the variable using const.
debugging/book-library/script.js
Outdated
| let readStatus = ""; | ||
| if (myLibrary[i].check == false) { | ||
| if (myLibrary[i].check == true) { | ||
| readStatus = "Yes"; | ||
| } else { | ||
| readStatus = "No"; | ||
| } | ||
| changeBut.innerText = readStatus; | ||
| toggleReadBtn.innerText = 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 79–85 as a single statement?
debugging/book-library/script.js
Outdated
| deleteBtn.dataset.index = i; | ||
| deleteCell.appendChild(deleteBtn); | ||
| deleteBtn.className = "btn btn-warning"; | ||
| deleteBtn.innerHTML = "Delete"; |
There was a problem hiding this comment.
Why assign text to a DOM element via three different properties?
- 'textContent` on line 71
innerTexton line 85innerHTMLon line 97
debugging/book-library/script.js
Outdated
| changeBut.className = "btn btn-success"; | ||
| wasReadCell.appendChild(changeBut); | ||
| let toggleReadBtn = document.createElement("button"); | ||
| toggleReadBtn.dataset.index = i; |
There was a problem hiding this comment.
What is the purpose of this statement? Where is the assigned value used in your code?
debugging/book-library/script.js
Outdated
| for (let n = rowsNumber - 1; n > 0; n-- ) { | ||
| table.deleteRow(n); | ||
| } |
There was a problem hiding this comment.
Could consider using a more efficient approach to clear the table.
cjyuan
left a comment
There was a problem hiding this comment.
The most recent changes look good, but they may have introduced a bug in the app.
Can you try adding a new book through the UI and see if the book list is still rendered correctly?
Self checklist