Skip to content

Instantly share code, notes, and snippets.

View 0xlkda's full-sized avatar
🇻🇳
code đi anh em

Alex 0xlkda

🇻🇳
code đi anh em
  • Viet Nam
  • 20:03 (UTC +07:00)
View GitHub Profile
@0xlkda
0xlkda / countryToFlag.js
Created July 24, 2021 18:48 — forked from hieunc229/countryToFlag.js
Get country flag using its code
// ISO 3166-1 alpha-2
// ⚠️ No support for IE 11
// Source: all over the internet
function countryToFlag(code) {
let isoCode = code.split("-").pop()
return typeof String.fromCodePoint !== 'undefined'
? isoCode
.toUpperCase()
.replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397))
: isoCode;