Skip to content

solution#1267

Open
UArtem87 wants to merge 1 commit intomate-academy:masterfrom
UArtem87:develop
Open

solution#1267
UArtem87 wants to merge 1 commit intomate-academy:masterfrom
UArtem87:develop

Conversation

@UArtem87
Copy link
Copy Markdown

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

Great job on this task! Your solution correctly implements all the required functionality for the growth table, and the logic for managing the button states is perfect. I am happy to approve your submission.

I have a couple of suggestions to help you write even more efficient code, which will be very useful in larger applications:

  • In src/scripts/main.js, it's a good practice to query for DOM elements like your buttons once when the script loads and store them in constants, rather than querying for them inside an event listener that runs on every click.
  • The countCell function is currently redefined on every click. Moving its definition outside the addEventListener callback will prevent this and improve performance.

Keep up the excellent 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
countCell();
}

function countCell() {
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 function is redefined every time the click event handler runs. It's more efficient and better for code organization to define countCell once, outside of the addEventListener callback.

Comment thread src/scripts/main.js
Comment on lines +39 to +42
document.querySelector('.append-row').disabled = rowCount >= 10;
document.querySelector('.remove-row').disabled = rowCount <= 2;
document.querySelector('.append-column').disabled = colCount >= 10;
document.querySelector('.remove-column').disabled = colCount <= 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.

Accessing elements with document.querySelector can be slow, and here it's happening four times on every click. It's a best practice to find these button elements once when the script loads, store them in constants, and then use those constants inside this function. This makes your code faster.

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