I have two arrays:
arr1 = [1, 2, 3, 1, 2, 3, 4]
arr2 = [1, 3, 1, 1]
arr3 = [1, 1, 2, 2, 3]
Using arr1
as the baseline, arr2
does not match because it contains three 1
's whereas arr1
only has two. arr3
, however should return true
because it has elements from arr1
.
I tried
if(_.difference(arr2, arr1).length === 0)
But this does not take into account the number of occurrences