For example I have an array as follows & expected output is given.
In javascript how can we determine dynamically how many levels are there in my array ary.
var ary = ["a","b",["c","d"],"e",["f","g",["h","i"],"j"]];
Output: 3
var ary = ["a","b",["c","d"],"e",["f","g","i"]];
Output: 2
var ary = ["a","b",["c",["d"]],"e",[["f","g",["i","j"]],"k"]];
Output: 4
currentDepthand amaxDepthvariable. Every time you exit a level of recursion decrementcurrentDepthbut keepmaxDepth.maxDepthis only increased if thecurrentDepthis greater than it. When you're done,maxDepthshould be the deepest nested "dimension" in your array.