Conversation
ATkachenkoA
commented
Jan 30, 2026
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great work on fetching the data and performing the calculations! The logic for getting the total and average is correct. However, one change is needed before this can be approved. The average population is currently displayed as NaN because of an incorrect order of operations. You are calling Math.round() on a string returned by toLocaleString(), which contains commas and cannot be rounded. To fix this, you should round the number before you format it as a string. Simply change the order to Math.round(average).toLocaleString() and the issue will be resolved.
✨ 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
|
|
||
| const formattedTotal = total.toLocaleString(); | ||
|
|
||
| const formattedAverage = Math.round(average.toLocaleString()); |
There was a problem hiding this comment.
The order of operations here is incorrect. average.toLocaleString() returns a string (e.g., "382,925,836.55..."), and Math.round() will not work correctly on a string that contains commas, resulting in NaN. You should round the number before converting it to a formatted string.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this submission! You've successfully addressed the feedback from the last review. The fix to round the average before formatting it was exactly right and has resolved the NaN issue. Your code now correctly calculates and displays the total and average population, meeting all the requirements. I am approving your solution. Well done!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨