I can’t seem to find an algorithm to compute the number of arrays within an array. Example
Given
[ [ "Array", "1" ], [ "Array", "2" ] ]
Output should be two
Given
[
[
[ ["Array", "1"], ["Array", "2"] ],
[ ["Array", "3"], ["Array", "4"] ],
],
[
[ ["Array", "5"], ["Array", "6"] ],
[ ["Array", "7"], ["Array", "8"] ]
]
]`
Output should be 8
This recursive function will do the job for arrays of any nesting: