looping through arrays of arrays

This recursive function should do the trick with any number of dimensions:

var printArray = function(arr) {
    if ( typeof(arr) == "object") {
        for (var i = 0; i < arr.length; i++) {
            printArray(arr[i]);
        }
    }
    else document.write(arr);
}

printArray(parentArray);

Leave a Comment