Skip to content

Instantly share code, notes, and snippets.

@EleotleCram
Created November 30, 2017 12:49
Show Gist options
  • Save EleotleCram/374ab6761dbd74e63a21f8d83bba163e to your computer and use it in GitHub Desktop.
Save EleotleCram/374ab6761dbd74e63a21f8d83bba163e to your computer and use it in GitHub Desktop.
// arrayDepth() => 0
// arrayDepth([]) => 1
// arrayDepth([[]]) => 2
// arrayDepth([[[]]]) => 3
// arrayDepth([[[[]]]]) => 4
const arrayDepth = (ary) => _.isArray(ary) ? 1+arrayDepth(ary[0]) : 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment