init#2259
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation successfully fulfills the core functional requirements. The code correctly parses population data from the DOM, calculates totals and averages, and formats the output with thousands separators. While the code works well for the expected inputs (numeric strings), the task requirement #2 does mention validating convertibility before conversion. Since your implementation handles the primary use case correctly and there are no test failures, this is approved. Consider adding a defensive check like Number.isNaN() as a best practice for robustness against unexpected data.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| src: url('../fonts/Roboto-Regular-webfont.woff') format('woff'); | ||
| font-weight: normal; | ||
| font-style: normal; | ||
| src: url('../fonts/Roboto-Regular-webfont.woff') format('woff'); |
There was a problem hiding this comment.
This conversion doesn't verify if the string can actually be converted to a number. The task requirement #2 states: 'Make sure that the given string can be converted to a number and convert it to number'. Consider checking if the result is NaN before including it in the populations array.
| // write your code here | ||
| const populationSpans = document.querySelectorAll('.population'); | ||
|
|
||
| const toNumber = (span) => Number(span.textContent.replace(/,/g, '')); |
There was a problem hiding this comment.
The task requires verifying that the string can be converted to a number before converting. Currently, this will produce NaN for non-numeric strings. Consider adding a check like isNaN() to filter out or handle non-convertible values.
No description provided.