-
Notifications
You must be signed in to change notification settings - Fork 966
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
solution #976
base: master
Are you sure you want to change the base?
solution #976
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.
Great job on implementing the core functionality of appending and removing rows and columns! 🎉 The code meets the task requirements and constraints effectively. However, there are a couple of critical issues that need attention:
-
deleteRow
Method Usage: Ensure that you pass the correct index to thedeleteRow
method, as it should take an index rather than a row object. This will prevent potential errors when trying to delete rows. -
Cell Count Check: Before checking the number of cells, make sure the table has at least one row and one cell to avoid errors when accessing
table.rows[0].cells.length
.
Once these issues are addressed, your code will be even more robust. Keep up the great work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
removeRow.addEventListener('click', () => { | ||
const row = table.rows[table.rows.length - 1]; | ||
|
||
table.deleteRow(row); |
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 deleteRow
method should take an index as an argument, not a row object. You should pass table.rows.length - 1
directly to deleteRow
instead of row
.
table.rows[i].deleteCell(-1); | ||
} | ||
|
||
if (table.rows[0].cells.length === 2) { |
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.
Ensure that the table has at least one cell before checking the number of cells. If the table is empty, accessing table.rows[0].cells.length
will cause an error. Consider adding a check to ensure there is at least one row and one cell before this line.
DEMO LINK