Created
July 17, 2017 14:26
-
-
Save masnagam/cf646b20f7f4aefa64a6ff9012d05aa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function getDepth(element, depth) { | |
let maxDepth = depth; | |
for (let i = 0; i < element.children.length; ++i) { | |
let childDepth = getDepth(element.children[i], depth + 1); | |
if (maxDepth < childDepth) { | |
maxDepth = childDepth; | |
} | |
} | |
return maxDepth; | |
} | |
return getDepth(document.documentElement, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment