AlgoLounge

Canadian Province Validator

easy

Determine if a given string represents a Canadian province (not territory). Accept both full names and abbreviations.

Valid Provinces: Alberta (AB), British Columbia (BC), Manitoba (MB), New Brunswick (NB), Newfoundland and Labrador (NL), Nova Scotia (NS), Ontario (ON), Prince Edward Island (PE), Quebec (QC), Saskatchewan (SK)

Examples

Example 1

Input:  "Alberta"
Output: true

Example 2

Input:  "Yukon"
Output: false

Yukon is a territory, not a province

Constraints

  • Case may vary
  • Accepts abbreviations
  • Territories return false
TypeScript
Loading editor…
List of test cases (10)
Case 1
name = "Alberta"
Case 2
name = "Yukon"
Case 3
name = "ON"
Case 4
name = "Quebec"
Case 5
name = "Northwest Territories"
Case 6
name = "BC"
Case 7
name = "british columbia"
Case 8
name = "Saskatchewan"
Case 9
name = "Nunavut"
Case 10
name = "NS"