Reputation: 65
I need to reverse this condtion, That means United States
to US
. I try to find out on Google but can't. How can I do it?
let regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
console.log(regionNames.of('US')); // "United States"
Upvotes: 1
Views: 539
Reputation: 1689
This library should help
https://www.npmjs.com/package/country-code-lookup
// search by country name
lookup.byCountry('United Kingdom')
Upvotes: 0