-
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
add task solution #983
base: master
Are you sure you want to change the base?
add task solution #983
Conversation
MaksymKolesnyk
commented
Feb 18, 2025
- DEMO LINK
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 functionality to add and remove rows and columns with the specified constraints! 🎉 While the code meets the task requirements, consider adding checks to handle cases where the table might start with fewer rows or columns than expected. This will make your solution more robust and prevent potential errors. Keep up the good work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
for (let i = 0; i < table.rows[1].cells.length; i++) { | ||
newRow.insertCell(); | ||
} |
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 loop assumes that there is at least one row with cells in the table. If the table is initially empty or has fewer rows than expected, this could lead to errors. Consider adding a check to ensure the table has at least one row before accessing table.rows[1].cells.length
.
if (table.rows.length > 2) { | ||
table.deleteRow(-1); | ||
} |
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 condition assumes there are always at least two rows in the table. If the table starts with fewer rows, this could cause issues. Consider adding a check to ensure the table has the minimum required rows before attempting to delete.
if (ar[1].cells.length < 10) { | ||
for (const element of ar) { | ||
element.insertCell(); | ||
} | ||
} |
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 condition assumes there are always at least two columns in the table. If the table starts with fewer columns, this could cause issues. Consider adding a check to ensure the table has the minimum required columns before attempting to add more.
if (ar[1].cells.length > 2) { | ||
for (const element of ar) { | ||
element.deleteCell(-1); | ||
} | ||
} |
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 condition assumes there are always at least two columns in the table. If the table starts with fewer columns, this could cause issues. Consider adding a check to ensure the table has the minimum required columns before attempting to delete.