We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ecc4a1 commit 19f2d4cCopy full SHA for 19f2d4c
deepCompare_7/deepCompare.js
@@ -0,0 +1,26 @@
1
+//deep comparison of multi-dimensional arrays with recursion
2
+
3
+const deepCompare = (a, b) => {
4
+ let res = true
5
6
+ if(Array.isArray(a) && Array.isArray(b))
7
+ {
8
+ let count = 0;
9
10
+ while(res && count < a.length)
11
12
+ res = !a.some( (val, i) => {
13
+ return !deepCompare(val, b[i])
14
+ })
15
16
+ count++
17
+ }
18
19
+ else
20
21
+ res = (a === b)
22
23
24
+ return res
25
26
+}
0 commit comments