First attempt#2301
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there are still critical issues that block the task from being fully completed. First, the selector for the average span uses the class .avarage-population instead of the required .average-population, so your computed average is never written to the correct element [CHECKLIST ITEM #6]. Please update both the class name in the JavaScript and any related variable names so the span with class="average-population" is correctly targeted and updated.
Second, you directly call Number(cleanedText) without first confirming that cleanedText is a valid numeric string, which violates the requirement to ensure the string can be converted to a number before conversion [CHECKLIST ITEM #14]. You can fix this by adding a guard such as if (!isNaN(cleanedText) && cleanedText !== '') or a regex check before pushing to populationNumbers and including only valid entries in your calculations. Once these issues are corrected, your logic for collecting, summing, averaging, and formatting the population values should satisfy the task requirements. Overall, your core approach looks solid; these targeted fixes will bring it fully in line with the specification.
✨ 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 populationNumbers = [...populationSpans].map(span => { | ||
| const text = span.textContent; | ||
| const cleanedText = text.replace(/,/g, ''); | ||
| return Number(cleanedText); |
There was a problem hiding this comment.
The task requires making sure the string can be converted to a number before converting it; here you directly call Number(cleanedText) without any validation. Consider checking that the cleaned text represents a valid numeric value (e.g., via regex or isNaN) before including it in populationNumbers, per checklist item #14.
| const avarage = Math.round(total / populationNumbers.length); | ||
|
|
||
| const totalSpan = document.querySelector('.total-population'); | ||
| const avarageSpan = document.querySelector('.avarage-population'); |
There was a problem hiding this comment.
The class name here (.avarage-population) does not match the task description, which specifies average-population. This will prevent the average value from being written to the correct span and violates checklist item #6.
First attempt commit.