I have an array of objects like this located within a JSON file called zips.JSON:
[ {
"Company": "Company1",
"ZIP_CODE": "87121",
"Group": "Albuquerque, New Mexico",
"Dispatcher ID": "412333",
"Group ID": "1234431",
"CITY": "Albuquerque",
"STATE": "NM",
"Same Day Dispatcher ID": "1245245"
},
{
"Company": "Company1",
"ZIP_CODE": "87120",
"Group": "Albuquerque, New Mexico",
"Dispatcher ID": "12348",
"Group ID": "12349",
"CITY": "Albuquerque",
"STATE": "NM",
"Same Day Dispatcher ID": "12340"
},
{
"Company": "Company1",
"ZIP_CODE": "87111",
"Group": "Albuquerque, New Mexico",
"Dispatcher ID": "12347",
"Group ID": "12346",
"CITY": "Albuquerque",
"STATE": "NM",
"Same Day Dispatcher ID": "12345"
}
} ]
I also have a variable:
let zipCode = "87121"
How do I go through the array of objects and check if the variable zipCode that I have declared matches any of the key values for ZIP_CODE in the array? Then if so execute some simple function like
console.log("It matches")