{operation: {status: "success", text: "Approved"} , anotherOperation: {status: "success", text: "Approved"}, op: {status: "error", text: "Declined, because..."}}
const obj = {
operation: {
status: "success",
text: "Approved"
} ,
anotherOperation: {
status: "success",
text: "Approved"
},
op: {
status: "error",
text: "Declined, because..."
}
};
const textsArray = Object.values(obj).filter(el => el.status === 'error').map(el => el.text);
// результат: ["Declined, because..."]
for (var key in YourObject) {
var obj = YourObject[key];
if (obj.status === "error") {
console.log(obj.text);
}
}