Answers for "How to know if two arrays have the same values"

0

How to know if two arrays have the same values

function sameMembers(arr1, arr2) {
    const set1 = new Set(arr1);
    const set2 = new Set(arr2);
    return arr1.every(item => set2.has(item)) &&
        arr2.every(item => set1.has(item))
}
Posted by: Guest on July-20-2021

Code answers related to "How to know if two arrays have the same values"

Browse Popular Code Answers by Language