haveSameContents
Checks if two arrays contain the same elements regardless of order.
- Use a
for...ofloop over aSetcreated from the values of both arrays. - Use
Array.prototype.filter()to compare the amount of occurrences of each distinct value in both arrays. - Return
falseif the counts do not match for any element,trueotherwise.