Last active
February 16, 2023 17:15
-
-
Save rarous/ce77b8f8690b0ec84824de2e270bb8d1 to your computer and use it in GitHub Desktop.
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
/** | |
* 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