Skip to content

Commit

Permalink
add tast solution
Browse files Browse the repository at this point in the history
  • Loading branch information
hma-3 committed Sep 12, 2024
1 parent 9b73549 commit a35b428
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 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/)
- [DEMO LINK](https://hma-3.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
13 changes: 12 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
'use strict';

// write your code here
const populanions = [...document.querySelectorAll('span.population')].map(
(num) => Number(num.innerText.split(',').join('')),
);

const total = populanions.reduce((sum, num) => sum + num, 0);
const average = total / populanions.length;

const innerTextTotal = document.querySelector('span.total-population');
const innerTextAvarage = document.querySelector('span.average-population');

innerTextTotal.innerText = total.toLocaleString('en-US');
innerTextAvarage.innerText = average.toLocaleString('en-US');

0 comments on commit a35b428

Please sign in to comment.