Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add task solution #1533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1. Replace `<your_account>` with your Github username in the link
- [DEMO LINK](https://<your_account>.github.io/js_get_data_DOM/)
1. Replace `rekverr` with your Github username in the link
- [DEMO LINK](https://rekverr.github.io/js_get_data_DOM/)
2. Follow [this instructions](https://mate-academy.github.io/layout_task-guideline/)
- There are no tests for this task so use `npm run lint` command instead of `npm test`
- There are no tests for this task so use `npm run lint` command instead of `npm test`

### Task: TOP 10 LARGEST COUNTRIES BY POPULATION

Expand Down
25 changes: 25 additions & 0 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
'use strict';

// write your code here
const population = [...document.querySelectorAll('.population')];
const totalPopulation = document.querySelector('.total-population');
const averagePopulation = document.querySelector('.average-population');

let total = 0;

const setting = population

Choose a reason for hiding this comment

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

There is a missing semicolon at the end of this line. It's important to maintain consistency in your code style.

.map((el) => {
return el.textContent;
})
.map((el) => {
return el.replaceAll(',', '');

Choose a reason for hiding this comment

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

The method replaceAll is not supported in all browsers. Consider using a more compatible method like replace with a global regular expression.

})
.map((el2) => {
return +el2;
});

for (const ch of setting) {
total += ch;
}

const average = total / setting.length;

totalPopulation.textContent = total;
averagePopulation.textContent = average;
Loading