Need to filter the arr
based on check
values. I am unable to filter inside the getItems
function.
let check = ["DIS_1","DIS_2","DIS_6","DIS_10"]
let arr = [{otherProperty: "",cr: [{cc: "DIS_1", cv: "cal1"},{cc: "first", cv: "cal2"},{cc: "DIS_2", cv: "cal3"}]},
{otherProperty: "",cr: [{cc: "DIS_6", cv: "cal4"},{cc: "second", cv: "cal5"},{cc: "DIS_10", cv: "cal6"}]},
{otherProperty: "",cr: [{cc: "third", cv: "cal7"},{cc: "fourth", cv: "cal8"},{cc: "DIS_1", cv: "cal9"}]}
]
let expectedOutput = [{otherProperty: "",cr: [{cc: "DIS_1", cv: "cal1"},{cc: "DIS_2", cv: "cal3"}]},
{otherProperty: "",cr: [{cc: "DIS_6", cv: "cal4"},{cc: "DIS_10", cv: "cal6"}]},
{otherProperty: "",cr: [{cc: "DIS_1", cv: "cal9"}]}
]
function getItems(arr) {
console.log('--arr', arr)
}
console.log('expect', getItems(arr))