This seems to have been answered here https://stackoverflow.com/questions/62028827/how-to-get-country-name-from-country-code-in-javascript
Nov 9, 2021
13
Level 7
Javascript how to get Country code from country name?
Hi,
I would like to get the country code from a country name using plain vanilla javascript?
United Kingdom = UK
South Africa = ZA
Level 104
@boyjarv If you have an Array, you can find an element using a callback, e.g.:
let found = countryListAllIsoData.find(country => country.name === races.Circuit.Location.country);
let code = found ? found.code3 : 'n/a';
Please or to participate in this conversation.