-
-
Save yussan/35139421063f5547fe18f7e7e0fa5a8e to your computer and use it in GitHub Desktop.
Convert a country's ISO-2 string to a flag emoji in a single line
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 iso2FlagEmoji = iso => String.fromCodePoint(...[...iso.toUpperCase()].map(char => char.charCodeAt(0) + 127397)); | |
iso2FlagEmoji("US"); // "🇺🇸" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment