Skip to content

Instantly share code, notes, and snippets.

@yycking
Created February 7, 2025 05:32
Show Gist options
  • Save yycking/9bc810dac563d90f179534cefed91403 to your computer and use it in GitHub Desktop.
Save yycking/9bc810dac563d90f179534cefed91403 to your computer and use it in GitHub Desktop.
country code to emoji flag
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => '🇦'.codePointAt() + char.codePointAt() - 'A'.codePointAt() );
return String.fromCodePoint(...codePoints);
}
console.log(getFlagEmoji('EU'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment