|
|
|
@ -58,6 +58,10 @@ const Main = ({ numbers }) => (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
//Population
|
|
|
|
|
function numberWithCommas(x) {
|
|
|
|
|
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Country = ({ countries }) => {
|
|
|
|
|
const countryList = countries.map((country) =>
|
|
|
|
|
<tr className='tr'>
|
|
|
|
@ -68,7 +72,7 @@ const Country = ({ countries }) => {
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td className='td-value'>
|
|
|
|
|
{new Intl.NumberFormat('ru-RU').format(country.population)}
|
|
|
|
|
{numberWithCommas(country.population)}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
)
|
|
|
|
@ -79,7 +83,7 @@ const Country = ({ countries }) => {
|
|
|
|
|
const Population = ({ countries, count }) => (
|
|
|
|
|
<main>
|
|
|
|
|
<h1>{count} most populated countries in the world</h1>
|
|
|
|
|
<Country countries={countries} />
|
|
|
|
|
<table className='table'><Country countries={countries} /></table>
|
|
|
|
|
</main>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|