Using your object format...
Example to case-sensitively search for:
banana AND (bicycle OR motorcycle)
var obj = {
"a":["apple","banana"],
"b":["fish","apple","car","run","jump"],
"c":["car","truck","motorcycle","banana"],
"d":["banana","boat","car","bicycle"]
};
var result = [];
//test each obj arrays
for (var i in obj) {
//skip array if no banana
if (obj[i].indexOf('banana') < 0) continue;
//check for bicycle or motorcycle
//in each array element
for (var j = 0; j < obj[i].length; j++) {
if (
(obj[i][j] == 'bicycle') ||
(obj[i][j] == 'motorcycle')
) {
//found one. save result
result.push(i);
//no need to search further
break;
}
}
}
console.log(result);
//shows: ["c", "d"]
//or...
console.log(result.join(''));
//shows: cd