Created
March 29, 2022 09:37
-
-
Save sunpietro/22b10927e427c22f97b8db24f444a753 to your computer and use it in GitHub Desktop.
Get country flag as emoji
This file contains hidden or 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
const getEmojiFlag = (code) => { | |
const codePoints = code | |
.toUpperCase() | |
.split('') | |
.map(char => 127397 + char.charCodeAt()); | |
return String.fromCodePoint(...codePoints); | |
} | |
getEmojiFlag('pl'); // 🇵🇱 | |
getEmojiFlag('us'); // 🇺🇸 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment