Skip to content

Instantly share code, notes, and snippets.

View Niels-NTG's full-sized avatar
🍅

Niels NTG Poldervaart Niels-NTG

🍅
View GitHub Profile
@Niels-NTG
Niels-NTG / flag.js
Last active November 1, 2020 13:28
Construct flag emoji from ISO 3166-1 2 letter country code
/*
* Constructs an emoji flag using a supported ISO 3166-1 2 letter country code.
*
* Per character in the input string it shifts it 127365 code points from the ASCII lower case
* characters to Regional Indicator Symbol series, which is used to construct flag emoji.
*
* @param {String} regionCode String starting with a supported ISO 3166-1 2 letter region code.
* @returns {String} Emoji flag character constructed from 2 regional indicator symbols.
*/
function flag(regionCode = '') {