Created
October 28, 2022 00:18
-
-
Save richietyler/896c05aef771ea62972c2d1dfbfb604b to your computer and use it in GitHub Desktop.
Simple function to convert Canadian province/territory codes to names
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
function caProvinceCodesToNames(stateCode) { | |
const code = stateCode.toLowerCase(); | |
if (code === "ab") { | |
return "Alberta" | |
} else if (code === "bc") { | |
return "British Columbia" | |
} else if (code === "mb") { | |
return "Manitoba" | |
} else if (code === "nb") { | |
return "New Brunswick" | |
} else if (code === "nl") { | |
return "Newfoundland and Labrador" | |
} else if (code === "ns") { | |
return "Nova Scotia" | |
} else if (code === "on") { | |
return "Ontario" | |
} else if (code === "pe") { | |
return "Prince Edward Island" | |
} else if (code === "qc") { | |
return "Quebec" | |
} else if (code === "sk") { | |
return "Saskatchewan" | |
} else if (code === "nt") { | |
return "Northwest Territories" | |
} else if (code === "nu") { | |
return "Nunavut" | |
} else if (code === "yt") { | |
return "Yukon" | |
} else { | |
return "You haven't entered a valid CA province or territory code" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment