Skip to content

Solution#2261

Open
mariiamad wants to merge 3 commits into
mate-academy:masterfrom
mariiamad:develop
Open

Solution#2261
mariiamad wants to merge 3 commits into
mate-academy:masterfrom
mariiamad:develop

Conversation

@mariiamad
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js Outdated
Comment on lines +8 to +11
const cleaned = country.textContent.replaceAll(',', '');
const number = Number(cleaned);

total += number;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/styles/main.scss
Comment on lines +8 to 11
justify-content: center;

width: 100vw;
height: 100vh;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

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. Rate AI review example

Comment thread src/scripts/main.js Outdated
@@ -1,3 +1,24 @@
/* eslint-disable no-unused-vars */
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove this unused eslint-disable comment as there are no unused variables in the code.

Comment thread src/styles/_fonts.scss
@@ -1,6 +1,6 @@
@font-face {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/styles/main.scss
@@ -1,15 +1,19 @@
@import 'fonts';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The eslint-disable no-unused-vars comment is no longer needed since all declared variables are used. Remove this comment.

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