Reference · Australian country module
getStateFromAustralianPostcodefunction
The state or territory whose block of postcodes a postcode is in. A postcode that also serves a town across a border
still gives the state of its block; getStatesForAustralianPostcode gives them all.
Import it
import { getStateFromAustralianPostcode } from "@johnmorrisdotca/address-plus/au";
Definition
function getStateFromAustralianPostcode(postcode: string): AustralianStateCode | undefined
Parameters
| Name | Type | Description |
|---|---|---|
postcode | string | Four digits, with or without spaces around them. |
Returns
AustralianStateCode | undefined
The state's code, or undefined when the text is not four digits or no block holds it.
Examples
import { getStateFromAustralianPostcode } from "@johnmorrisdotca/address-plus/au";
console.log(getStateFromAustralianPostcode("2620"));
// → "NSW"NSWWhat it prints (run when this page was built)