-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
West-Midlands-Community | Matthew Law | Module-Data-Flows | WEEK 11 | Book Library #143
base: main
Are you sure you want to change the base?
West-Midlands-Community | Matthew Law | Module-Data-Flows | WEEK 11 | Book Library #143
Conversation
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.
All the bugs described in the spec have been successfully fixed.
There are also some errors in the index.html
.
for (let n = rowsNumber - 1; n > 0; n-- { | ||
|
||
// Delete old rows | ||
for (let n = rowsNumber - 1; n > 0; 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.
Can you think of a more efficient way to remove all rows (except the <th>...</th>
) in the table?
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.
Yes, there is a more efficient way to remove all rows (except the elements) in the table. The entire can be cleared in a single operation by setting its innerHTML to an empty string.
debugging/book-library/script.js
Outdated
delBut.className = "btn btn-warning"; | ||
delBut.innerHTML = "Delete"; | ||
delBut.addEventListener("clicks", function () { | ||
delButton.id = i + 5; |
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.
- Is the value assigned to this
id
attribute unique? - Is there a need to assign an id attribute to
delButton
? - Is there a need to assign an id attribute to
changeBut
(at line 62)? - Can you think of a more consistent way to name the variables representing the two buttons?
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.
@cjyuan Yes you are right. After reviewing the need for id attributes for the buttons, I determined that they are not necessary I’ve opted to use data-* attributes to manage element associations. I have also changed the variable name for the buttons to be more clear "deleteButton" and "toggleButton"
debugging/book-library/script.js
Outdated
delButton.addEventListener("click", function () { | ||
alert(`You've deleted title: ${myLibrary[i].title}`); | ||
myLibrary.splice(i, 1); | ||
render(); | ||
}); |
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.
At the moment when the alert message is displayed, has the book mentioned in the message been deleted yet?
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.
Thank you for pointing this out @cjyuan. I have moved the alert message to occur after the book deletion
Hi @cjyuan if everything is alright here. I'll make this as complete. Thank you for helping me reviewing my code. |
yes. all good |
Self checklist
Changelist
PR is for completing exercises.
Questions
Ask any questions you have for your reviewer.