Created
June 4, 2019 03:18
-
-
Save sandgraham/1ee713da09f7e0d10548cf9ad8c399cb 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 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