solution#2153
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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:
- 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
NaNfrom being displayed. - 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
| const arrOfValues = [...populations] | ||
| .map((el) => el.textContent.replaceAll(',', '')) | ||
| .map(Number); |
There was a problem hiding this comment.
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.
| totalPopulation.toLocaleString(); | ||
|
|
||
| document.querySelector('.average-population').textContent = | ||
| averagePopulation.toLocaleString(); |
There was a problem hiding this comment.
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.
|
|
||
| body { | ||
| background: #eee; | ||
| counter-reset: section; |
There was a problem hiding this comment.
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.
| src: url('../fonts/Roboto-Regular-webfont.woff') format('woff'); | ||
| font-weight: normal; | ||
| font-style: normal; | ||
| src: url('../fonts/Roboto-Regular-webfont.woff') format('woff'); |
There was a problem hiding this comment.
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.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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.jsis modified. Please revert the changes made tosrc/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
| const arrOfValues = [...populations] | ||
| .map((el) => el.textContent.replaceAll(',', '')) | ||
| .map(Number); |
There was a problem hiding this comment.
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.
| .map(Number); | ||
|
|
||
| const totalPopulation = arrOfValues.reduce((acc, value) => acc + value, 0); | ||
| const averagePopulation = totalPopulation / arrOfValues.length; |
There was a problem hiding this comment.
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.
| height: 100vh; | ||
| justify-content: center; | ||
| align-items: center; | ||
| justify-content: center; |
There was a problem hiding this comment.
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.
No description provided.