diff --git a/README.md b/README.md index 36dc318d..f0e670ba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ 1. Replace `` with your Github username in the link - - [DEMO LINK](https://.github.io/js_get_data_DOM/) + - [DEMO LINK](https://ArtemBehter.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` diff --git a/src/scripts/main.js b/src/scripts/main.js index c6e3f878..64c07f14 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,13 @@ 'use strict'; -// write your code here +const listPopulation = [...document.querySelectorAll('.population')]; +const arrPopulation = listPopulation.map(item => + +item.textContent.split(',').join('')); + +const totalpopulation = arrPopulation.reduce((a, b) => a + b); + +document.querySelector('.total-population').textContent += totalpopulation.toLocaleString('en-US'); + +document.querySelector('.average-population').textContent += (totalpopulation / arrPopulation.length).toLocaleString('en-US');