Last active
September 30, 2021 07:52
-
-
Save ferreiro/d300473d192db8c97fb593d4d72d1445 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
// Generated based on https://en.wikipedia.org/wiki/ISO_4217 | |
// Make sure here you pass the two letters country code, if you find countryCodes with more digits | |
// and it's not in this list, make sure to add that. | |
const COUNTRY_CODE_TO_CURRENCY = { | |
// EUROS | |
AX: "EUR", | |
EU: "EUR", | |
AD: "EUR", | |
AT: "EUR", | |
BE: "EUR", | |
CY: "EUR", | |
EE: "EUR", | |
FI: "EUR", | |
FR: "EUR", | |
TF: "EUR", | |
DE: "EUR", | |
GR: "EUR", | |
GP: "EUR", | |
IE: "EUR", | |
IT: "EUR", | |
LV: "EUR", | |
LT: "EUR", | |
LU: "EUR", | |
MT: "EUR", | |
GF: "EUR", | |
MQ: "EUR", | |
YT: "EUR", | |
MC: "EUR", | |
ME: "EUR", | |
NL: "EUR", | |
PT: "EUR", | |
RE: "EUR", | |
BL: "EUR", | |
MF: "EUR", | |
PM: "EUR", | |
SM: "EUR", | |
SK: "EUR", | |
SI: "EUR", | |
ES: "EUR", | |
VA: "EUR", | |
// GBP | |
GB: "GBP", | |
IM: "GBP", | |
JE: "GBP", | |
GG: "GBP", | |
SHN: "GBP", | |
// INDIAN RUPEE | |
IN: "INR", | |
BT: "INR", // buthan | |
}; | |
function getCurrency(countryCode) { | |
if (countryCode in CURRENCIES_BY_COUNTRIES) { | |
return COUNTRY_CODE_TO_CURRENCY[countryCode]; | |
} | |
return "USD"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment