Let's say i have array 1
const arr1 = [[45, 63],[89],[90]]
and array 2
const arr2 = [45, 63]
To check if arr2 or values from arr2 exist in arr1 it's easy doing the next function
private contains(arr1, opts) {
const stringifiedOpts = JSON.stringify(opts);
return arr1.some(item => JSON.stringify(item) === stringifiedOpts);
}
in this case contains() function will return true.
This was first simplest case. Now let's say that:
arr2 = [45, 63, 90]
function contains() will return false because arr1 doesn't contain [45, 63, 90] but contains [90] as different array. In this case function should return true because 90 from arr2 exist in arr1
My question it's what kind of logic should i have in that function to return true when:
arr2 = [45, 63, 90] or
arr2 = [45, 90] or
arr2 = [63, 89] or
arr2 = [63, 90] or
arr2 = [81, 20, 90] or
arr2 = [25, 60, 89]
because 90 or 89 exist in arr1 but as different arrays
Any help/ideas/solutions here are welcome guys. Thanks!