Using the node package: npm install countries-list
, found here (where there is a bit of info on usage:
https://www.npmjs.com/package/countries-list
We have countries
which gives us an object of all the countries, and we have languages
which gives us an object of all the languages. I want to map languages to the correct countries.
So I get the countries like this
const countryNames = [], langs = [];
let idx = 0;
for(const c of Object.values(countries)) {
countryNames[idx] = <Dropdown.Item>{c.name}</Dropdown.Item>;
// get the language of the country at countryNames[idx]
idx++;
}
We can get the countrycode like so: getCountryCode(c.name)
. What would then be reasonable to do (in my head), would be something like:
langs[idx] = <Dropdown.Item>{languages[getCountryCode(c.name)].languages[0].name}</Dropdown.Item>;
But languages
and countries
do not share the same code. How can I go about this?