I have the following data:
const myArr = [{
id: 0,
company: "microsoft",
location: "berlin"
}, {
id: 1,
company: "google",
location: "london"
}, {
id: 2,
company: "twitter",
location: "berlin"
}];
let myObj = {
company: ["google", "twitter"],
location: ["london"]
}
and given that the myObj.company entries are changing (irrelevant how) I am trying to create a function that filters results and only returns Objects that satisfy the location and company criteria.
In the example above, what we need returned is :
{
id: 1,
company: "google",
location: "london"
}
If myObj was
let myObj = {
company: ["google", "twitter"],
location: []
}
then the returned result should be
{
id: 1,
company: "google",
location: "london"
},
{
id: 2,
company: "twitter",
location: "berlin"
}
Array.prototype.filter()+Array.prototype.some()