Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because a core requirement is not met: the displayed total and average must include thousands separators. This is a functional requirement for output formatting and directly affects correctness of the result shown to users.
Critical issues to fix:
- In
src/scripts/main.js, the values assigned tospan.total-populationandspan.average-populationare not formatted with thousands separators. The task requires using a thousands separator (e.g.,toLocaleString()orIntl.NumberFormat). Update the assignments so thattotal.toLocaleString()andaverage.toLocaleString()(or equivalent) are used when settingtextContent.
Why this matters: without proper formatting, the UI does not match the specified display style for populations, failing the requirement.
Minor suggestion:
- Consider handling the case of zero items to avoid
NaNin the average, and decide on rounding for the average if many decimals appear (e.g.,Math.roundor fixed decimals) before formatting.
You did a solid job parsing and computing values; add the formatting and this will meet the requirements. Keep it up!
✨ 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
| const total = populations.reduce((sum, population) => sum + population, 0); | ||
| const average = total / populations.length; | ||
|
|
||
| document.querySelector('.total-population').textContent = total; |
There was a problem hiding this comment.
The total value needs to be formatted with thousands separators (e.g., using toLocaleString()) to match the display style of source populations as required by the task.
| const average = total / populations.length; | ||
|
|
||
| document.querySelector('.total-population').textContent = total; | ||
| document.querySelector('.average-population').textContent = average; |
There was a problem hiding this comment.
The average value needs to be formatted with thousands separators (e.g., using toLocaleString()) to match the display style of source populations as required by the task.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Here is my approval: your implementation correctly collects all .population spans, strips formatting, converts to numbers, filters out non-numerics, and computes both total and average safely (guarding against empty inputs). The results are displayed in .average-population and .total-population with thousands separators via toLocaleString(), and the average is rounded, which satisfies the requirement to present a clean number. There are no critical blockers; functionality aligns with the task and handles edge cases gracefully.
Minor suggestions (non-blocking): consider specifying a locale in toLocaleString('en-US') for consistent separators across environments, and verify linting locally to match project style rules. Great job addressing the earlier formatting details and delivering a clear, robust solution.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.