How to find the highest dimension of a multi-dimensional array?

There is an array,
arr = [2,[2],[[[2]]],3]

My code should return, 4.
Because [[[2]]] is in the 4th dimension as well as the highest dimension of arr.

You could count with a while loop or recursion.

1 Like