I'm trying to see If a certain key, "channel" will exist in an array of objects. The array can have a single object or multiple. If there are multiple we need to check if they exist
The Example Below Has multiple
This is What I have currently, it works for a single object but not multiple
var obj = [
{
"Movies": {
"7364234": "hsjd",
"tom and jerry": "dsjdas",
"mickey mouse": "kfjskdsad",
"popeye the sailor man": "alkdsajd",
"channel": "kasjdsjad"
}
},
{
"Movies": {
"73642348": "hsjd",
"terry and jon": "dsjdas",
"mickey rat": "kfjskdsad",
"popeye the sailor women": "alkdsajd",
"channel": "kasjdsjad"
}
}
];
if ( typeof obj[0]["Movies"]["channel"] !== 'undefined' ) {
console.log('exists');
} else {
console.log('does not exist');
}