Skip to content

Instantly share code, notes, and snippets.

@remy727
Created February 11, 2024 12:54
Show Gist options
  • Save remy727/968e466a6c61bf636f54aeb91650b28e to your computer and use it in GitHub Desktop.
Save remy727/968e466a6c61bf636f54aeb91650b28e to your computer and use it in GitHub Desktop.
Get Country name from Country code using JavaScript
const regionNames = new Intl.DisplayNames(
['en'], {type: 'region'}
);
console.log(regionNames.of('US')); // 👉️ "United States"
console.log(regionNames.of('GB')); // 👉️ "United kingdom"
console.log(regionNames.of('DE')); // 👉️ "Germany"
console.log(regionNames.of('AU')); // 👉️ "Australia"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment