getProvinceFromSpanishPostcodefunction
The province a postcode is in, as its ISO 3166-2 code without ES-: the province its first two digits name.
Import it
import { getProvinceFromSpanishPostcode } from "@johnmorrisdotca/address-plus/es";
Definition
function getProvinceFromSpanishPostcode(postcode: string): string | undefined
Parameters
| Name | Type | Description |
|---|---|---|
postcode | string | The postcode. |
Returns
string | undefined
The province's code (M for Madrid), or undefined when the postcode has not the shape.
Examples
import { getProvinceFromSpanishPostcode } from "@johnmorrisdotca/address-plus/es";
console.log(["28014", "08001", "41001", "35001", "1234"].map(getProvinceFromSpanishPostcode));
// → ["M","B","SE","GC",null][ 'M', 'B', 'SE', 'GC', undefined ]What it prints (run when this page was built)