Skip to content

Instantly share code, notes, and snippets.

@sandgraham
Created June 4, 2019 03:18
Show Gist options
  • Save sandgraham/1ee713da09f7e0d10548cf9ad8c399cb to your computer and use it in GitHub Desktop.
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
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