Skip to content

Conversation

@VladChudin
Copy link

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

Excellent work on the core logic! You've successfully parsed the data, calculated the total and average, and formatted the output correctly.

I'm requesting one change to fully meet the task requirements. The instructions specify to "Make sure that the given string can be converted to a number." Your current implementation is missing this validation step. Without it, non-numeric data could lead to NaN (Not a Number) in your results, which would break the display.

To fix this, please add a check to ensure a string is a valid number before you convert and add it to the populations array. A simple if condition using !isNaN() would be a great way to handle this. This change will make your code more robust and complete.


✨ 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


populationSpans.forEach((span) => {
const text = span.textContent;
const number = Number(text.replace(/,/g, ''));

Choose a reason for hiding this comment

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

According to the task requirements, you need to "Make sure that the given string can be converted to a number". This implementation assumes the conversion will always be successful. Consider adding a check (e.g., using !isNaN(number)) to ensure you only push valid numbers to the populations array. This makes your code more robust against unexpected data.

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 addressing the feedback! You've successfully added the validation to check if a string can be converted to a number before it's used in any calculations. Your solution is now robust, clean, and fully meets all the task requirements. I'm happy to approve this submission. 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