const areEqual = (arr1, arr2) => arr1.sort().join(',') === arr2.sort().join(','); const arr1 = [1, 2, 3, 4]; const arr2 = [3, 4, 1, 2]; const arr3 = [1, 2, 3]; console.log(areEqual(arr1, arr2)); // true console.log(areEqual(arr1, arr3)); // false