I\'m trying to write a function that will loop through my object and return the level depth of the object.
For example, if I ran the function on this object:
In the function
function getMaxDepth(root) { var currentMaxDepth = 0; return getDepth(currentMaxDepth, root); }
You call getDepth with root, but root is never changed. So it is always the same. You should call for instance,
return getDepth(currentMaxDepth, root.children[0]);