I am dealing with an array that contains sub-arrays, each of which may have different lengths. For example:
let arrayA = [
[['a'] , ['b','c','d']], //lengths 1 and 3
[['e','f','g','z'], ['h','i','j']], //lengths 4 and 3
[['k','l'] , ['m','n']] //lengths 2 and 2
//sums 7 and 8
]
The goal is to calculate the sum of the lengths of each sub-subarray based on the index of the sub-array it belongs to:
let arrayB = [[7],[8]]
What would be the most effective approach to accomplish this task?