Skip to content

Develop#2144

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

Develop#2144
AndrewPrszn wants to merge 3 commits intomate-academy:masterfrom
AndrewPrszn:develop

Conversation

@AndrewPrszn
Copy link
Copy Markdown

- [DEMO LINK](https://AndrewPrszn.github.io/js_get_data_DOM/)

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

Good work on this task! You've correctly implemented the logic to calculate and display the population data. However, one key requirement needs to be addressed before this can be approved. The task description specifies that you must 'Make sure that the given string can be converted to a number'. Your current code assumes this conversion will always be successful.

In src/scripts/main.js, if a <span> contained non-numeric text, the entire calculation would result in NaN. To fix this, please add a check after converting the string to a number to verify it's not NaN before you add it to the total. Using !isNaN() is a great way to handle this. This change will make your code more robust and fully meet the task requirements.


✨ 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

for (const el of populations) {
const text = el.textContent;
const number = Number(text.replace(/,/g, ''));
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 description requires you to 'Make sure that the given string can be converted to a number'. This code assumes the conversion will always be successful. Consider adding a check after this line to verify that number is not NaN before you use it in calculations on the next line. This will make your code more robust against unexpected data in the HTML.

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 submission! I am approving your changes. You've done a great job addressing the feedback from the last review by adding the !isNaN check to ensure the population data is handled correctly. This makes the code more robust and reliable. All requirements for the task have now been fully met. Keep up the great work!


✨ 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