Design comparison
Solution retrospective
It was a really fun challenge! I
had some problem though with converting the alpha-3 country codes to country names. I tried with the Intl.DisplayNames method but it only works with alpha-2 codes. So i simply had to fetch the API again and get the names of the border countries that way. If there is a simpler way to solve this it would be nice to know.
Other feedback is also appreciated!
Community feedback
- @tomashoj2001Posted over 1 year ago
Hi! It´s going so well :) My way to get the borders is:
countries .filter(c => borders.includes(c.cca3)) .map(c => c.common)
Countries is the API response and borders is the array of borders in the country in which you are.
With the filter I´m taking ALL the data from the countries that includes cca3 name (such as 'SWE' for Sweden) and with the map I´m taking the common name of the filtered countries.
I hope my explanation was clear!
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord