Skip to content

Instantly share code, notes, and snippets.

@rarous
Last active February 16, 2023 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rarous/ce77b8f8690b0ec84824de2e270bb8d1 to your computer and use it in GitHub Desktop.
Save rarous/ce77b8f8690b0ec84824de2e270bb8d1 to your computer and use it in GitHub Desktop.
/**
* Converts Alpha‑2 country code (ISO 3166) to unicode flag emoji
* @param {String} countryCode
* @returns {String}
*/
export function flagEmoji(countryCode) {
const s = countryCode.toUpperCase();
return String.fromCodePoint(
127397 + s.charCodeAt(0),
127397 + s.charCodeAt(1)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment