JSFiddle - React, Tailwind, and code Playground
JavaScript
Obj = {
1 : {
name : 'bob',
dinner : 'pizza'
},
2 : {
name : 'john',
dinner : 'sushi'
},
3 : {
name : 'larry',
dinner : 'sushi'
}
}
function getSushiObjects(Obj){
var foundObjects = [];
for (prop in Obj){
if (Obj[prop]['dinner'] === 'sushi'){
foundObjects.push(Obj[prop]);
}
}
return foundObjects;
}
var allSushiObjects = getSushiObjects(Obj);
console.log(allSushiObjects[0]);
console.log(allSushiObjects[1]);