I'm learning by doing js and jQuery.
I have a geocoder input (mapbox) and I need to check if the entered address is eligible for a specific service.
More specifically, I need to check if the zipcode is in our database of supported areas. The input zipcode is defined as the variable "userplz".
In both cases (is available or is not available) a specific class is added to an html element for visual representation. Also the result get's saved to localStorage.
I'm doing this with:
switch (userplz) {
case '14129':
case '14532':
$('#availability').append(available);
availability.classList.add('available','pulse-green');
localStorage.setItem('available',"yes");
break;
default:
$('#availability').append(unavailable);
availability.classList.add('unavailable','pulse-red');
localStorage.setItem('available',"no");
};
Now I don't want to edit the script every time we expand our service area. Ideally I'd save a file with eligible zipcodes somewhere in in the page directory and import the file into my script. Therefore I only have to update the file and not the script, every time we update our supported zipcodes.
Any help is appreciated. Best regards, Vincent