generated from mate-academy/gulp-template
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d245e1
commit 82279c0
Showing
3 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
'use strict'; | ||
|
||
// write your code here | ||
const populationList = document.querySelectorAll('.population'); | ||
const totalPopulation = document.querySelector('.total-population'); | ||
const averagePopulation = document.querySelector('.average-population'); | ||
|
||
let total = 0; | ||
|
||
populationList.forEach(population => { | ||
const count = population.textContent.split(',').join(''); | ||
|
||
total += +count; | ||
}); | ||
|
||
const average = total / populationList.length; | ||
|
||
totalPopulation.textContent = total | ||
.toLocaleString('en-US'); | ||
|
||
averagePopulation.textContent = average | ||
.toLocaleString('en-US'); |