Created
February 7, 2025 05:32
-
-
Save yycking/9bc810dac563d90f179534cefed91403 to your computer and use it in GitHub Desktop.
country code to emoji flag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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