Skip to content

js_get_data_DOM - #2307

Open
142536Def wants to merge 1 commit into
mate-academy:masterfrom
142536Def:develop
Open

js_get_data_DOM#2307
142536Def wants to merge 1 commit into
mate-academy:masterfrom
142536Def:develop

Conversation

@142536Def

Copy link
Copy Markdown
  1. Replace <142536Def> with your Github username in the link
  2. Follow this instructions
    • There are no tests for this task so use npm run lint command instead of npm test

Task: TOP 9 LARGEST COUNTRIES BY POPULATION

Hello! In this task, you need to parse data from the list, and based on it get the average and total value.
You no need to change styles or HTML layout in this task. Change only main.js file.

Steps to do this challenge:

  1. Get all text data from span with class population
  2. Make sure that the given string can be converted to a number and convert it to number.
  3. Calculate average and total value-based to parsed numbers.
  4. Replace Calculate it! with calculated average numbers in span with classes average-population and total-population.
  5. Calculated average and total numbers must be separated by a thousands separator (same numeric style as populations presented).
  6. Congrats, mate! You did it!

Preview.

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

Copy link
Copy Markdown

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 because it correctly implements all of the core functional requirements for this task. Your main.js code gathers all .population spans, strips the thousands separators, converts the values to numbers, and then accurately computes both the total and the average. You then replace the Calculate it! placeholders in .total-population and .average-population with the computed values, formatting them using toLocaleString('en-US') so the output matches the given population style. You also respected the technical constraints by leaving the HTML and SCSS files unchanged and implementing the logic only in main.js. The only potential improvement (not a blocker) would be to defensively check for NaN before adding values to the total, in case any unexpected non-numeric text appears in a .population span in the future. Overall, this is a clear, focused solution that meets the task requirements well.


✨ 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