Is it possible to query a range of objects for a specific value before you do anything with it? For example, I will be getting a JSON structure similar to below with a set of properties:
"Properties": [
{
"Name": "product",
"Values": [ "Jacket", "Shirt", "Trousers" ]
},
{
"Name": "color",
"Values": [ "Red", "Blue", "Green" ]
}
]
Once I've loaded the JSON in my JS, I would like to be able to ask something like "go through each object in the array - if Name equals 'product', do something, if Name equals 'color', do something else" and so on.
I was thinking it would be something similar to the below, but so far no luck. I'm guessing it's because I'm trying to query a value in a child of Properties.
if (Properties.hasOwnProperty('Name') === "product") {
alert('Yes');
} else {
alert('No');
}
Predictably, the above snippet is returning "No" even when a Name property has the value "product".