Skip to content

task complete#1273

Open
Dimononon wants to merge 1 commit intomate-academy:masterfrom
Dimononon:dev
Open

task complete#1273
Dimononon wants to merge 1 commit intomate-academy:masterfrom
Dimononon:dev

Conversation

@Dimononon
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Excellent work on this task! All the requirements have been met: the buttons for adding and removing rows and columns work as expected, and they are correctly disabled at the minimum and maximum limits. I am approving your solution. As a point of improvement, consider making your row counting more robust. You are currently using table.rows.length for checks, but manipulating rows in table.tBodies[0]. Using table.tBodies[0].rows.length consistently for both checking and manipulation would prevent potential bugs if a <thead> element were added to the table. This is a great habit for writing more resilient code. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread src/scripts/main.js
const removeColumnButton = document.querySelector('.remove-column');

appendRowButton.addEventListener('click', (button) => {
if (table.rows.length < 10) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When checking the number of rows, you're using table.rows, which includes any header (<thead>) or footer (<tfoot>) rows. However, you are adding rows specifically to table.tBodies[0]. To avoid bugs if the table structure changes, it's safer to count rows from the same place you are modifying them. Consider using table.tBodies[0].rows.length instead.

Comment thread src/scripts/main.js
table.tBodies[0].appendChild(row);
}

if (table.rows.length === 10) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check for the maximum row count has the same issue as the one on line 11. It should also use table.tBodies[0].rows.length to be consistent and avoid potential bugs with tables that have a header.

Comment thread src/scripts/main.js
});

removeRowButton.addEventListener('click', (button) => {
if (table.rows.length > 2) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The row count check here should be consistent with the row manipulation logic. Please use table.tBodies[0].rows.length to ensure the logic works correctly even if the table has a <thead>.

Comment thread src/scripts/main.js
table.tBodies[0].deleteRow(-1);
}

if (table.rows.length === 2) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check for the minimum number of rows should also use table.tBodies[0].rows.length for consistency with the DOM manipulation and the other checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants