I am working on a web app where I need to get the user’s zip code and see if it matches one of the zips in csv file of 6000 zip codes (if yes, enter; else display error;) I was going to do this in sql and make a query with user’s input but wanted to know if there is a better approach (speed and other suggestions). Javascript preferred. Thanks.
Share
SQL’s probably the easiest/fastest.
As a fun experiment, though, if you really wanted to do it in JavaScript, you could read in the file and create an index of sorts by splitting each number as a string into its characters, and then creating a multidimensional hash for the lookup.
You could then compare that performance to a simple Array.indexOf() call.
Those’re probably reasonably fast but more work than needed, just go w/ the SQL. 😉