Skip to content

Instantly share code, notes, and snippets.

@yussan
Forked from sandgraham/iso2FlagEmoji.js
Created June 21, 2022 03:35
Show Gist options
  • Save yussan/35139421063f5547fe18f7e7e0fa5a8e to your computer and use it in GitHub Desktop.
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
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