fn
getCountryFlagByCode
v0.0.5Convert an ISO 3166-1 alpha-2 country code (e.g. 'RU', 'us')
into its flag emoji by mapping each letter to a Unicode regional indicator
symbol. Case-insensitive; returns an empty string for anything that isn't two
ASCII letters. Pure and environment-agnostic.
Example
ts
getCountryFlagByCode('RU'); // '🇷🇺'
getCountryFlagByCode('us'); // '🇺🇸'
getCountryFlagByCode('123'); // ''Signature
ts
export function getCountryFlagByCode(code: string): string{ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
code | string | The ISO 3166-1 alpha-2 code, e.g. 'US' |
Returns
stringThe flag emoji (e.g. '🇺🇸'), or '' when the code is invalid