@theAspiringDev1Submitted over 4 years ago
Please enlighten me how to change the border country code to its name. Thank you
Please enlighten me how to change the border country code to its name. Thank you
The names in the borders array are in the alpha3Code format.
In every country object, there is a field that stores the name of the country in this alpha3Code.
Apply the map method in the border array, iterating over the data from the api to find the countries where the border = alpha3code, and then replace it.
//data is the data from the api
borders = borders
.map(
(current) =>{
data.forEach((country)=>{
if( country.alpha3Code === current)
current = country.name
})
return `<a href="detail.html?=${current}"><div class="button">${current}</div></a>`
}
)