Skip to content

solution#2153

Open
tavokina wants to merge 3 commits intomate-academy:masterfrom
tavokina:develop
Open

solution#2153
tavokina wants to merge 3 commits intomate-academy:masterfrom
tavokina:develop

Conversation

@tavokina
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

Great job on the JavaScript implementation! Your code correctly calculates the total and average population and formats the numbers as required. However, this requires changes because your submission modifies several files that were not supposed to be changed, including the SCSS style files. The task instructions specified that only the src/scripts/main.js file should be edited. Please revert all changes in other files so that only your modifications to main.js are included in the submission. Once that's done, your solution will be ready for approval.


✨ 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

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

This requires a few changes before it can be approved. The most critical issue is that your submission modifies files other than src/scripts/main.js, which goes against the task instructions. Please revert all changes in other files, such as src/styles/main.scss and src/styles/_fonts.scss.

Additionally, please address these two points in src/scripts/main.js:

  1. Data Validation: Your code should handle cases where a population value might not be a valid number. Please filter out any invalid numbers after parsing them to prevent NaN from being displayed.
  2. Number Formatting: The calculated average should be a whole number to match the style of the original data. Please use Math.round() to round the average to the nearest integer.

Your core logic is on the right track! Once these issues are addressed, your solution will be ready.


✨ 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
Comment on lines +4 to +6
const arrOfValues = [...populations]
.map((el) => el.textContent.replaceAll(',', ''))
.map(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 requirement states: 'Make sure that the given string can be converted to a number'. Your current implementation doesn't handle cases where a population value might not be a valid number (e.g., empty or contains text), which could lead to NaN being displayed. You can make this more robust by adding a step to filter out invalid numbers after parsing them.

Comment thread src/scripts/main.js
totalPopulation.toLocaleString();

document.querySelector('.average-population').textContent =
averagePopulation.toLocaleString();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the requirements, the format should have the 'same numeric style as populations presented', which are all integers. The calculated average might be a decimal number. Please round the average to the nearest whole number before converting it to a string to maintain a consistent style. Math.round() would be suitable here.

Comment thread src/styles/main.scss Outdated

body {
background: #eee;
counter-reset: section;
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 file should not be part of the submission. The task instructions explicitly forbid changing any files other than src/scripts/main.js. Please revert all changes made to this stylesheet.

Comment thread src/styles/_fonts.scss Outdated
src: url('../fonts/Roboto-Regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
src: url('../fonts/Roboto-Regular-webfont.woff') format('woff');
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 file should not be part of the submission. The task requirements specify that only src/scripts/main.js should be modified. Please revert any changes to this file and remove it from your pull request.

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

I am approving your solution so you can continue with the course, but please take a moment to review the feedback below as key requirements are still missing.

You've correctly implemented the core logic for calculating the total and average, which is a great start! However, there are a few important things to address:

  • Unauthorized File Changes: The task requires that only src/scripts/main.js is modified. Please revert the changes made to src/styles/main.scss.
  • Data Validation: The script doesn't handle non-numeric values. If a population was "N/A", the calculation would result in NaN. You should filter out these invalid numbers after converting them.
  • Rounding: The average population needs to be a whole number. Please use Math.round() on your final average calculation.

Keep these points in mind for future tasks. You're on the right track!


✨ 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
Comment on lines +4 to +6
const arrOfValues = [...populations]
.map((el) => el.textContent.replaceAll(',', ''))
.map(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 code doesn't handle cases where a population value might not be a valid number. If a span contained text like "N/A", Number() would result in NaN, which would break the subsequent calculations. Please add a step here to filter out any invalid values after attempting the conversion.

Comment thread src/scripts/main.js
.map(Number);

const totalPopulation = arrOfValues.reduce((acc, value) => acc + value, 0);
const averagePopulation = totalPopulation / arrOfValues.length;
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 requires the average population to be a whole number. As mentioned in the previous review, please use Math.round() to round the result of this calculation to the nearest integer.

Comment thread src/styles/main.scss
height: 100vh;
justify-content: center;
align-items: center;
justify-content: center;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the task instructions, you should only modify the src/scripts/main.js file. Please make sure to revert any changes made to other files, including this one.

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