Skip to content

Instantly share code, notes, and snippets.

View akumbhani66's full-sized avatar
🎯
Focusing

Ashvin Kumbhani akumbhani66

🎯
Focusing
View GitHub Profile
Array.length will give you the number of top-level elements in an array.
Your task is to create a function deepCount that returns the number of ALL elements within an array, including any within inner-level arrays.
For example:
deepCount([1, 2, 3]);
//>>>>> 3
deepCount(["x", "y", ["z"]]);
//>>>>> 4