1const a = [1, 2, 3];
2const b = [4, 5, 6];
3const c = [1, 2, 3];
4
5function arrayEquals(a, b) {
6 return Array.isArray(a) &&
7 Array.isArray(b) &&
8 a.length === b.length &&
9 a.every((val, index) => val === b[index]);
10}
11
12arrayEquals(a, b); // false
13arrayEquals(a, c); // true
1var arraysMatch = function (arr1, arr2) {
2
3 // Check if the arrays are the same length
4 if (arr1.length !== arr2.length) return false;
5
6 // Check if all items exist and are in the same order
7 for (var i = 0; i < arr1.length; i++) {
8 if (arr1[i] !== arr2[i]) return false;
9 }
10
11 // Otherwise, return true
12 return true;
13
14};
15