var data_filter = data.filter( element => element.zip == "12180")
console.log(data_filter)
I have this so far which gets me 1 zip code match but I have 126, how do I rewrite this to return results for all entries that contain any of those 126 zip codes
I’m not a developer, just trying to run some reports on data in our system
2
Answers
The easiest way to accomplish your task would be to start by creating an array of the 126 zip codes, so there’s something to compare to. If there’s any useful pattern to it you could use that to generate the list, but it’s probably going to need to be done by hand.
Once you have the list, you can use something like:
Note that the zip code in the array
zipCodes
is a string and not a number, so that the stringelement.zip
will match it whenArray.includes
goes searching.Do you want to use filters to filter out the data you specify?