Skip to content

add task solution#2298

Open
yevheniia-biliaieva wants to merge 1 commit into
mate-academy:masterfrom
yevheniia-biliaieva:develop
Open

add task solution#2298
yevheniia-biliaieva wants to merge 1 commit into
mate-academy:masterfrom
yevheniia-biliaieva:develop

Conversation

@yevheniia-biliaieva

@yevheniia-biliaieva yevheniia-biliaieva commented Jul 6, 2026

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. Rate AI review example

Comment thread src/scripts/main.js
const populationValues = [];

for (const population of populations) {
const value = Number(population.textContent.replace(/,/g, ''), 10);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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