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
1// the answer when the index is not important
2function arrSimilar(arr1, arr2) {
3
4 // first lets check if the length is the same
5 if (arr1.length !== arr2.length) {return false}
6 let notSimilarItemsCounter = 0
7 arr1.map((item) => {
8 !arr2.includes(item) ? notSimilarItemsCounter++ : true ;
9 })
10 if ( notSimilarItemsCounter ) {
11 return false
12 }else {return true}
13}
14
15//byQolam