Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active August 3, 2022 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/c3cb4ea28932cf5309726a1c7759be92 to your computer and use it in GitHub Desktop.
Save McLarenCollege/c3cb4ea28932cf5309726a1c7759be92 to your computer and use it in GitHub Desktop.
Total Length of Nested SubArray

Given a nested array write a function that returns the total length of the nested subarrays.

CODE TEMPLATE


function totalLength(arr){
// write your code here
}

let myArray = [[1,2,3],[],[false,'vivek'],[]];
totalLength(myArray);//5
myArray = [[1],[],[false,'vivek'],[5,6,7,8,9]];
totalLength(myArray);//8
myArray = [];
totalLength(myArray);//0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment