Managing a collection of complex objects that require filtering based on multiple conditions
var myList= [
{
"UserId": 1,
"UserDetails": {
"Department": [
{
"Name": "dept1"
}
],
"Projects": [
{
"Name": "Project1"
},
{
"Name": "Project2"
}
]
}
},
{
"UserId": 2,
"UserDetails": {
"Department": [
{
"Name": "dept2"
}
],
"Projects": [
{
"Name": "Project3"
},
{
"Name": "Project4"
}
]
}
},
{
"UserId": 3,
"UserDetails": {
"Department": [
{
"Name": "dept3"
}
],
"Projects": [
{
"Name": "Project5"
},
{
"Name": "Project6"
}
]
}
}
]
I need to filter based on two criteria: when Department Name is "dept3" or if there is a project with the Name "Project3"
var filteredElements=this.myList.filter((x)=>x.UserDetails.filter((y)=>y.Department... ??
How can I implement code to handle these dual filtering conditions?