I am trying to get the name of country by its border name.
const countryList = [
{ name: 'France', cca3: 'FRA' },
{ name: 'Austria', cca3: 'AUT' },
{ name: 'Belgium', cca3: 'BEL' }
{ name: 'Brazil', cca3: 'BRA' }
];
const country = [
{
name: {
common: 'Germany'
}
},
{cca3: "DEU"},
{ borders: ['AUT', 'BEL', 'FRA']}
]
I loop over the "borders" of the "country" e.g. Germany. I need to get the name of the borders from the "countryList" by its "cca3".
So for Germany, the borders should be: France, Austria, Belgium
This is what i am trying to do, no my strong side.. can't get it work.
const getCountryBordersName = () => {
const borderName = () => {
country[0].borders.map((item) => countryList.find((code) => code.item = code).name)
}
return borderName;
}
console.log(getCountryBordersName());