solution#1267
Conversation
UArtem87
commented
Feb 25, 2026
- DEMO LINK https://UArtem87.github.io/js_growth_table_DOM/
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
countCellfunction is currently redefined on every click. Moving its definition outside theaddEventListenercallback 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
| countCell(); | ||
| } | ||
|
|
||
| function countCell() { |
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this comment.
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.