Conversation
timurradkevic
commented
Apr 6, 2026
- DEMO LINK
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job on implementing the logic to calculate the total and average population! The calculations are working correctly, and the numbers are formatted perfectly.
However, this requires changes because the current implementation modifies the page's HTML structure, which is against a key requirement. Using replaceWith() removes the <span> elements entirely. The goal is to update the text inside these spans, not to replace the elements themselves. Please consider using a property like element.textContent to set the new values.
As a smaller suggestion for improvement, you could combine the two loops that iterate over the population data into a single loop to make the code more efficient. This isn't a required change, but it's a good practice to keep in mind.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| for (const el of populationArr) { | ||
| if (isNaN(el.textContent.replaceAll(',', ''))) { | ||
| throw new Error('Population element not a number'); | ||
| } | ||
| } | ||
|
|
||
| for (const el of populationArr) { | ||
| sumPopul += Number(el.textContent.replaceAll(',', '')); | ||
| } |
There was a problem hiding this comment.
These two loops iterate over the same populationArr array. You can combine the validation and the summation logic into a single loop to make the code more efficient and easier to read.
| total.replaceWith(sumPopul.toLocaleString()); | ||
| average.replaceWith(avgPopul.toLocaleString()); |
There was a problem hiding this comment.
Using replaceWith() removes the <span> elements from the page, which alters the HTML structure. The task requires you to replace the text content of the spans (Calculate it!), not the elements themselves. Consider using a property like .textContent to update the text inside the existing elements.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this pull request! I am approving your solution as you've successfully addressed all the feedback from the previous review. Using element.textContent is the perfect way to update the values without altering the HTML structure. Your code is clean, efficient, and meets all the task requirements. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨