Solution#2261
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation is mostly solid, handling element selection, calculations, DOM updates, and thousands formatting correctly. However, there's a critical gap in requirement #2 - the task explicitly requires validating that strings can be converted to numbers before conversion, but your code directly converts without any NaN checks. In src/scripts/main.js, when Number(cleaned) receives a non-numeric string, it returns NaN, and adding NaN to your total variable corrupts the entire calculation. You must add validation before adding to the total: const number = Number(cleaned); if (!isNaN(number)) { total += number; count++; } This check ensures only valid, parseable numbers are included in your calculations, which is exactly what requirement #2 demands. The fix is straightforward - validate before adding to the sum, and increment your counter only when a valid number is found. There's also an unused eslint-disable comment for 'no-unused-vars' in your code that can be removed.
✨ 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 cleaned = country.textContent.replaceAll(',', ''); | ||
| const number = Number(cleaned); | ||
|
|
||
| total += number; |
There was a problem hiding this comment.
The task requirement #2 specifies 'Make sure that the given string can be converted to a number and convert it'. Currently, the code converts without validation. Consider checking if (!isNaN(number)) before adding to the total to ensure only valid numbers are included in calculations.
| justify-content: center; | ||
|
|
||
| width: 100vw; | ||
| height: 100vh; |
There was a problem hiding this comment.
This line converts the string to a number but doesn't validate the conversion. The task requires ensuring the string can be converted before using it. Consider checking Number.isNaN(number) after conversion, or only adding to total if the conversion succeeds.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation successfully addresses all functional requirements from the task. The NaN validation check has been properly implemented (lines 12-15), population data is correctly parsed, totals and averages are calculated accurately, and numbers are formatted with thousands separators using toLocaleString('en-US'). The only remaining issue is the unused eslint-disable no-unused-vars comment on line 1 in src/scripts/main.js — this is a minor linting/style concern that doesn't affect functionality. Since all core requirements are met and the code works correctly, I'm approving this submission. Consider removing the eslint-disable comment to keep the code clean.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| @@ -1,3 +1,24 @@ | |||
| /* eslint-disable no-unused-vars */ | |||
There was a problem hiding this comment.
Remove this unused eslint-disable comment as there are no unused variables in the code.
| @@ -1,6 +1,6 @@ | |||
| @font-face { | |||
There was a problem hiding this comment.
This eslint-disable comment for 'no-unused-vars' is not needed - the code doesn't have any unused variables. Remove this line to clean up the code.
| @@ -1,15 +1,19 @@ | |||
| @import 'fonts'; | |||
There was a problem hiding this comment.
The eslint-disable no-unused-vars comment is no longer needed since all declared variables are used. Remove this comment.
No description provided.