Skip to main content Accessibility Feedback

getFlagEmoji.js

Get the flag emoji for a two-letter country code.

/**
 * Get the flag emoji for the country
 * @link https://dev.to/jorik/country-code-to-flag-emoji-a21
 * @param  {String} countryCode The country code
 * @return {String}             The flag emoji
 */
function getFlagEmoji (countryCode) {
	let codePoints = countryCode.toUpperCase().split('').map(char =>  127397 + char.charCodeAt());
	return String.fromCodePoint(...codePoints);
}