These are the two arrays I'm working with. My goal is to ensure that every value in ValuesToBeCheckArr
is present in ActualArr. If any values are missing from ActualArr
, the function should return 0 or false. Additionally, there is an operator variable that can have a value of either AND
or OR
. I have successfully implemented a solution for the OR
operator but am struggling to come up with one for the AND
operator.
ActualArr = [1,2,3,4,5,6,7,21,25,35,50,132];
ValuesToBeCheckArr = [2,3,50,132];
Operator = AND/OR
if(Operator == AND) {
//check every value of ValuesToBeCheckArr should be in the ActualArr
} else if(Operator == OR) {
//check at least one value of ValuesToBeCheckArr should be in the ActualArr
const checkIncluded = (arr1, arr2) => arr1.some(item => arr2.includes(item));
const isIncluded1 = checkIncluded(["1", "2"], ["3"]) // true
}