Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 973 Bytes

README.md

File metadata and controls

58 lines (38 loc) · 973 Bytes

CountryCodes

A simple Javascript UMD tool for ISO country codes.

Usage

<script
  crossorigin
  src="https://raw.githubusercontent.com/jayPare/CountryCodes/main/countryCodes.js"
></script>

Country name to 2-digits code:

code = countryCodes.countryToCode("Canada"); // code == "CA"

Country name to 3-digits code:

code = countryCodes.countryToCode3("Canada"); // code == "CAN"

2-digits code to 3-digits code:

code = countryCodes.codeToCode3("CA"); // code == "CAN"

3-digits code to 2-digits code:

code = countryCodes.codeToCode3("CAN"); // code == "CA"

2-digits code to country name:

code = countryCodes.codeToCountry("CA"); // code == "Canada"

3-digits code to country name:

code = countryCodes.code3ToCountry("CAN"); // code == "Canada"

Notes

  • Missing countries coming soon.

License

MIT © JayPare