different_cia_un_estimation = {
let cia, un, countries, joint;
cia = list_of_countries_by_median_age_cia_raw.map((d) =>
Object.assign(
{},
{
country: d["Country/Territory"],
median2020: d["2020 medians Combined"],
femaleMoreThanMale: d["2020 medians Difference (female minus male)"]
}
)
);
cia.map((d) => {
if (d["country"] === "United States") {
d["country"] = "United States of America";
}
});
un = list_of_countries_by_median_age_un_raw.map((d) =>
Object.assign(
{},
{
country: d["Region, subregion, country or area"],
median2020: d["2020"],
subRegion: d["subRegion"]
}
)
);
countries = un.map((d) => d.country);
countries = cia
.filter((d) => countries.indexOf(d.country) !== -1)
.map((d) => d.country);
let unFound, ciaFound;
joint = countries.map((country) => {
ciaFound = cia.find((d) => d.country === country);
unFound = un.find((d) => d.country === country);
return Object.assign(
{ country },
{
ciaMedian2020: ciaFound.median2020,
femaleMoreThanMale: ciaFound.femaleMoreThanMale,
unMedian2020: unFound.median2020,
subRegion: unFound.subRegion
}
);
});
return { cia, un, countries, joint };
}