Reference · Parsing, formatting and shared types
getZipPrefixesForStatefunction
The ZIP code prefixes a state or territory uses, the reverse of getStateFromZip: three digits where a whole block
of a hundred belongs to it, five where only part of one does. Every ZIP starting with one of them resolves to that
state.
Import it
import { getZipPrefixesForState } from "@johnmorrisdotca/address-plus";
Definition
function getZipPrefixesForState(state: string): string[]
Parameters
| Name | Type | Description |
|---|---|---|
state | string | The state or territory's two-letter code. |
Returns
string[]
The prefixes in ascending order, or an empty array for an unknown code.
Examples
import { getZipPrefixesForState } from "@johnmorrisdotca/address-plus";
console.log(getZipPrefixesForState("RI"));
// → ["028","029"][ '028', '029' ]What it prints (run when this page was built)