This is my Array (http://www.jsoneditoronline.org/?id=cc51a12581667055781639b586fa6e15):
[
{
"documents": [
{
"name": "a",
"isSelected": true,
"status": "good"
},
{
"name": "b",
"isSelected": false,
"status": "good"
}
]
},
{
"documents": [
{
"name": "a",
"isSelected": true,
"status": "bad"
},
{
"name": "b",
"isSelected": false,
"status": "good"
}
]
},
{
"documents": [
{
"name": "a",
"isSelected": true,
"status": "verygood"
},
{
"name": "b",
"isSelected": false,
"status": "good"
}
]
},
{
"documents": [
{
"name": "a",
"isSelected": false,
"status": "good"
},
{
"name": "b",
"isSelected": false,
"status": "good"
}
]
}
]
I need to write condition using _.lodash.
This condition has to return TRUE if in array is at least one Selected document with Status other than good or verygood
Based on array from above. http://prnt.sc/de3gx9 You can see on the screenshot that in array is an object with:
- isSelected
- Has other status than
goodorverygood
If in my Array is at least one object (with isSelected = true, and status = bad (or any other than good or verygood). Then I want to see RESULT: TRUE
function checkStatusInArray() {
var data = [....]; // this is my array
var isDocumentSelectedWithWrongStatus = _.some(data, { isSelected: true, status: !"good" || !"verygood" });
// So if in array are some items with isSelected = true and status != good || verygood, then isDocumentSelectedWithWrongStatus = TRUE
return isDocumentSelectedWithWrongStatus;
}