I have the following array:
arrayObject = [
{ type: "one" },
{ type: "two" },
{ type: "other" },
];
And I also have the following array with values:
types = [
"one",
"other"
];
What I need is to verify if these two values exist, if they do not exist I must prevent them from advancing in a flow, currently what I am doing is:
arrayObject.filter(object => types.includes(object.type))
And this code returns me when none exists, but also returns me when one or the other exists, however what I need is to know if those two exist or not, it does not work for me
Use every
if (types.every(t => arrayObject.findIndex(a => a.type === t) > -1))