-
-
Notifications
You must be signed in to change notification settings - Fork 160
Manchester| 25-ITP-SEP| Fithi Teklom| Sprint 2 | Book Library #361
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?
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.
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.
debugging/book-library/script.js
Outdated
| if (!title.value.trim() || !author.value.trim() || !pages.value.trim()) { | ||
| alert("Please fill all fields!"); | ||
| return false; | ||
| } |
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.
Indentation is off.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could consider using a more efficient approach to clear the table.
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.
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