Below are my data array and multiple search keys to search the data array.
let dataStore = [
{
fName: "Sachin",
level: ["L1"],
position: "Cricket",
},
{
fName: "Michale",
level: ["L1", "L2"],
position: "Football"
},
{
fName: "Smith",
level: ["L3"],
position: "Carrom"
},
{
fName: "Lara",
level: "L3",
position: "Chess"
},
{
fName: "Rose",
level: "L5",
position: "Swimming"
}
]
let searchByThis = {
position: ["Cricket", "Chess"],
level: "L1",
fName: "Lara"
}
Need to filter the dataStore array by the searchByThis object. It should return the result to all matching scenario. I have tried with find, filter but not getting the correct result for the above example. The search object, dataStore array may have array also sometimes.(example: position). Any way to find particular object by its key?