When calling this function I am expecting myStrings to be ['A','B','C','D','E','F','G'] when in fact I'm seeing ['A', 'B', 'G']. When the recursive call is made a[i] equals [['C','D'],'E','F'] however the function receives the entire myArray. Any ideas?
var myArray = ['A','B',[['C','D'],'E','F'],'G'];
var myStrings = [];
function extractStrings(a) {
for(var i=0; i<a.length; i++) {
if(typeof a[i] === 'string') {
myStrings.push(a[i]);
} else if (typeof a[i] === 'object') {
extractStrings[a[i]];
}
}
}
extractStrings(myArray);
console.log(myStrings);