I am trying to find if an object contains a certain value and then have that dictate the next steps of the operation. This is an object that is returned from Google Maps API. This is an exact example returned back from their API.
Array
[{'long_name': 'United States', 'short_name': 'US'}, {'long_name': 'California', 'short_name': 'CA'}];
Conditional/Check
if( $.inArray('US', array) == -1 ){
alert('Your country is not supported.');
} else {
alert('Your country is supported.');
}
This doesn't work because it only looks at the index, and not values I believe. What's the cleanest and fastest way to find and return if the value exists in the array?
arrayis an object, not an array.