Skip to content

Instantly share code, notes, and snippets.

@sacarino
Created July 21, 2023 01:48
Show Gist options
  • Save sacarino/2948d7b5170be6a299170fd037a1aa1c to your computer and use it in GitHub Desktop.
Save sacarino/2948d7b5170be6a299170fd037a1aa1c to your computer and use it in GitHub Desktop.
nstead of showing country codes (ie US, CH, NL), show the flag emojis, πŸ‡ΊπŸ‡Έ πŸ‡¨πŸ‡­ and πŸ‡³πŸ‡±
// thanks to https://dev.to/jorik/country-code-to-flag-emoji-a21
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment