Skip to content

add task solution#2233

Open
timurradkevic wants to merge 2 commits intomate-academy:masterfrom
timurradkevic:develop
Open

add task solution#2233
timurradkevic wants to merge 2 commits intomate-academy:masterfrom
timurradkevic:develop

Conversation

@timurradkevic
Copy link
Copy Markdown

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 implementing the logic to calculate the total and average population! The calculations are working correctly, and the numbers are formatted perfectly.

However, this requires changes because the current implementation modifies the page's HTML structure, which is against a key requirement. Using replaceWith() removes the <span> elements entirely. The goal is to update the text inside these spans, not to replace the elements themselves. Please consider using a property like element.textContent to set the new values.

As a smaller suggestion for improvement, you could combine the two loops that iterate over the population data into a single loop to make the code more efficient. This isn't a required change, but it's a good practice to keep in mind.


✨ 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 +6 to +14
for (const el of populationArr) {
if (isNaN(el.textContent.replaceAll(',', ''))) {
throw new Error('Population element not a number');
}
}

for (const el of populationArr) {
sumPopul += Number(el.textContent.replaceAll(',', ''));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These two loops iterate over the same populationArr array. You can combine the validation and the summation logic into a single loop to make the code more efficient and easier to read.

Comment thread src/scripts/main.js Outdated
Comment on lines +21 to +22
total.replaceWith(sumPopul.toLocaleString());
average.replaceWith(avgPopul.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.

Using replaceWith() removes the <span> elements from the page, which alters the HTML structure. The task requires you to replace the text content of the spans (Calculate it!), not the elements themselves. Consider using a property like .textContent to update the text inside the existing elements.

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

Excellent work on this pull request! I am approving your solution as you've successfully addressed all the feedback from the previous review. Using element.textContent is the perfect way to update the values without altering the HTML structure. Your code is clean, efficient, and meets all the task requirements. Great job!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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