I have a array object I want to return and if it will find in this array otherwise it will return or I want to just return value not key.
Currently it returns an object and I need only a value.
const arrObj = [
{
"relation_type": "undefined"
},
{
"relation_type": "or"
},
{
"relation_type": "and"
},
{
"relation_type": "or"
},
{
"relation_type": "or"
}
]
let obj = arrObj.find((o) => {
if (o.relation_type === "and") {
return true;
}
});
console.log(obj);
const result = arrObj.some(o => o.relation_type === 'and') ? 'and' : 'or'.