add task solution#2298
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution because the core functionality is correctly implemented: you read all .population spans, convert them to numbers, compute total and average, and update .average-population and .total-population with properly formatted values using toLocaleString('en-US'), satisfying the main behavioral requirements. The misuse of Number(..., 10) and the lack of an explicit NaN check are real issues, but they are not breaking the current functionality given the expected input; they are more about robustness and API correctness than core task completion. To strengthen your solution and fully align with the checklist (especially [CHECKLIST ITEM #4] and [CHECKLIST ITEM #16]), you should remove the unused radix argument and add a guard like:
const value = Number(population.textContent.replace(/,/g, ''));
if (Number.isNaN(value)) {
// handle invalid data (e.g., skip or log)
return;
}
populationValues.push(value);It’s also worth double-checking the project description to ensure your GitHub demo link uses your actual username and that linting (npm run lint) passes cleanly. Overall, your implementation meets the functional requirements well, and these suggested adjustments will help make your code more robust and aligned with best practices.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| const populationValues = []; | ||
|
|
||
| for (const population of populations) { | ||
| const value = Number(population.textContent.replace(/,/g, ''), 10); |
There was a problem hiding this comment.
Here you are using Number(population.textContent.replace(/,/g, ''), 10). The Number constructor/function ignores the second argument, so 10 has no effect, and there is no check that the result is actually a valid number. To satisfy checklist items #4 and #16, consider validating that the parsed value is not NaN (e.g., using Number.isNaN) before pushing it into populationValues, and remove the unused radix argument.
DEMO LINK