Skip to content

Commit

Permalink
add solution
Browse files Browse the repository at this point in the history
  • Loading branch information
xSviatoslaw committed Sep 7, 2024
1 parent 471edd9 commit e89d9ed
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
'use strict';

// write your code here
const populationElements = document.querySelectorAll('.population');

const totalPopulation = Array.from(populationElements)
.map(element => Number(element.textContent.replace(/,/g, '')))
.reduce((sum, value) => sum + value, 0);

const b = totalPopulation / 10;

document.querySelector('.total-population').textContent = totalPopulation.toLocaleString('en-US');
document.querySelector('.average-population').textContent = b.toLocaleString('en-US');

0 comments on commit e89d9ed

Please sign in to comment.