Skip to content

js_get_data_DOM#2185

Open
A1daros wants to merge 3 commits intomate-academy:masterfrom
A1daros:develop
Open

js_get_data_DOM#2185
A1daros wants to merge 3 commits intomate-academy:masterfrom
A1daros:develop

Conversation

@A1daros
Copy link

@A1daros A1daros commented Feb 16, 2026

No description provided.

Copy link

@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 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

// write your code here
const spanData = document.querySelectorAll('.population');
const convertedSpanData = Array.from(spanData).map((span) => {
span.textContent = span.textContent.trim().replace(/[,\s]/g, '');

Choose a reason for hiding this comment

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

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.

Copy link

@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 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! ✨

Footnotes

  1. Rate AI review example

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