I am trying to do filter an array based on flag isSome: true. I want to filter when that flag is not present in that array
var value = [
{ "somevalues": {},
"moreDetails": {
"isSome": "true"
}
},
{ "somevalues": {},
"moreDetails": {}
},
{ "somevalues": {},
"moreDetails": {}
},
]
const valuewithisSome = value.filter(o => o.moreDetails && o.moreDetails.isSome);
const valuewithoutisSome = value.filter(o => o.moreDetails && !o.moreDetails.isSome);
console.log(valuewithisSome);
console.log(valuewithoutisSome);
valuewithisSome is working as expected and returning array with isSome: true.
valuewithoutisSome is not working as expected as i don't want to pass isSome false in morevalues array, is there a way to filter without even passing that flag?