I have two arrays Arr1 = [1,1,1,2,2,2,3,3] Arr2 =[1,1,2,1]
Comparing both arrays should return True as there are same occurrences of no. 1.
However If Arr2 = [1,1,2] it should return false as the no. Of occurrences of 1 or 2 don't match with the no. Of occurrences of 1 and 2 in Arr1
Even Arr2 = [1,1,2,3,1] should return True.
Thanks in advance! Cheers
I tried this but doesn't work for other instances.
function allElementsPresent(first, second) {
return second.every((element) => first.includes(element));
}