Created
October 17, 2023 15:38
-
-
Save kevboutin/b9c987476fa7ed1845dc30e136a03cee to your computer and use it in GitHub Desktop.
Compare Arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment