Skip to content

add task solution#2166

Open
ATkachenkoA wants to merge 2 commits intomate-academy:masterfrom
ATkachenkoA:develop
Open

add task solution#2166
ATkachenkoA wants to merge 2 commits intomate-academy:masterfrom
ATkachenkoA:develop

Conversation

@ATkachenkoA
Copy link

- [DEMO LINK](https://ATkachenkoA.github.io/js_get_data_DOM/)

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


const formattedTotal = total.toLocaleString();

const formattedAverage = Math.round(average.toLocaleString());

Choose a reason for hiding this comment

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

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.

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

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