Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You may be better off testing for zip codes you do support...</p> <pre><code>function zipToState(zip){ var state, i= 0, next, statezips= [ [1000, 2792, 'MA'], [2800, 2941, 'RI'], [3030, 3898, 'NH'], [3900, 4993, 'ME'], [5000, 5496, 'VT'],[5500, 5545, 'MA'], [5600, 5908, 'VT'], [6000, 6390, 'CT'], [6389, 6391, 'NY'], [6400, 6929, 'CT'],[7000, 8990, 'NJ'], [10000, 14976, 'NY'], [15000, 19641, 'PA'], [19700, 19981, 'DE'], [20000, 20040, 'DC'], [20039, 20042, 'VA'], [20039, 20168, 'VA'], [20041, 20600, 'DC'], [20041, 20043, 'VA'], [20330, 20332, 'MD'], [20334, 20798, 'MD'], [20798, 20800, 'DC'], [20811, 21931, 'MD'], [22000, 24659, 'VA'], [24700, 26887, 'WV'], [27005, 28910, 'NC'], [29000, 29949, 'SC'], [30000, 32000, 'GA'], [32003, 34998, 'FL'], [35003, 36926, 'AL'], [37009, 38590, 'TN'], [38600, 39777, 'MS'], [39900, 39902, 'GA'], [40002, 42789, 'KY'], [43000, 46000, 'OH'], [46000, 47998, 'IN'], [48000, 49972, 'MI'], [50000, 52810, 'IA'], [53000, 54991, 'WI'], [55000, 56764, 'MN'], [57000, 57800, 'SD'], [58000, 58857, 'ND'], [59000, 59938, 'MT'], [60000, 63000, 'IL'], [63000, 65900, 'MO'], [66001, 67955, 'KS'], [68000, 68119, 'NE'], [68118, 68121, 'IA'], [68121, 69368, 'NE'], [70000, 71233, 'LA'], [71232, 71234, 'MS'], [71233, 71498, 'LA'], [71600, 72960, 'AR'], [73000, 73200, 'OK'], [73300, 73302, 'TX'], [73400, 74967, 'OK'], [75000, 75502, 'TX'], [75501, 75503, 'AR'], [75502, 80000, 'TX'], [80000, 81659, 'CO'], [82000, 83129, 'WY'], [83200, 83877, 'ID'], [84000, 84785, 'UT'], [85000, 86557, 'AZ'], [87000, 88442, 'NM'], [88509, 88590, 'TX'], [88900, 89884, 'NV'], [90000, 96163, 'CA'], [96700, 96899, 'HI'], [97000, 97921, 'OR'], [98000, 99404, 'WA'], [99500, 99951, 'AK'] ]; if(/^\d{5}$/.test(zip)){ zip= Number(zip.substring(0,5)); while(i&lt;72){ next= statezips[i++]; if(zip&gt; next[0] &amp;&amp; zip&lt; next[1]) return next[2]; } } return ''; } zipToState('04355') /* returned value: (String) ME */ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload