What am I missing here? This script looks right to me.
But for some reason when I send it a zipcode of 02897 (or anything that should be Rhode Island), it returns New Hampshire. Aside from political beliefs Javascript developers may have (sure most people would prefer to live in New Hampsire than Rhode Island), why doesn't this script work?
New Jersey and Alabama work fine. Why can't Rhode Island get some love?
function getState(zip) {
var thiszip = zip; // parseInt(zip);
if (thiszip >= 35000 && thiszip <= 36999) {
thisst = 'AL';
thisstate = "Alabama";
}
else if (thiszip >= 03000 && thiszip <= 03899) {
thisst = 'NH';
thisstate = "New Hampshire";
}
else if (thiszip >= 07000 && thiszip <= 08999) {
thisst = 'NJ';
thisstate = "New Jersey";
}
else if (thiszip >= 02800 && thiszip <= 02999) {
thisst = 'RI';
thisstate = "Rhode Island";
}
else {
thisst = 'none';
}
return thisst;
}