Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job implementing the core logic for the population calculations! The parsing and calculations are working correctly. However, this requires one change because your script has an unintended side effect: it modifies the original population numbers on the page, causing them to lose their comma formatting. This happens because you're updating the textContent of the <span> elements you are reading from. To fix this, you should read the textContent into a new variable, clean that variable, and then use it for your calculations, leaving the original DOM element untouched.
✨ 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
src/scripts/main.js
Outdated
| // write your code here | ||
| const spanData = document.querySelectorAll('.population'); | ||
| const convertedSpanData = Array.from(spanData).map((span) => { | ||
| span.textContent = span.textContent.trim().replace(/[,\s]/g, ''); |
There was a problem hiding this comment.
This line modifies the textContent of the original <span> element in the DOM. This is an unintended side effect that removes the formatting from the population numbers on the page. You should process the text without changing the original element. Consider storing the cleaned string in a new variable and using that for calculations.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this submission! I am approving your solution as you've successfully addressed the previous feedback. The script now correctly calculates the total and average population without modifying the original data on the page, meeting all project requirements. The implementation is clean and efficient. Well done!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.