The output doesn't print all array numbers

hello,

I try to print all the array’s properties but it doesn’t come out.

here is what i try:

 var myarr = [[1,2],[3,4],5,6];
        
        for (i=0; i<myarr.length; i++){
            for(j=0; j<myarr[i].length; j++){
               for(a=0; a<myarr[i][j].length; a++){
                   console.log(myarr[i][j][a]);
                   
               } 
                
                
            }
          
        }

Hey Randell,

that is what i meant:

[[1,2],[3,4],5,6];

an array with 4 properties.

It doesn’t print anything.

yes that’s what i try

thanks randell,

by adding the array.isarray method you help the machine to validated that myarr[i] is an array, then the j can run. Did i get it right?

ok, so why in this example total is equal to 9 instead of 15?

var myarr = [1,2,3,[4,5]];
        
        var total = 0;
        
        for (i=0; i<myarr.length; i++){
            if (Array.isArray(myarr[i])){
            for (j=0; j<myarr[i].length; j++){
                
            
            total += myarr[i][j];
            }
        }
            else {
                console.log("no");
            }
        }
        console.log(total);

i understand now, thanks! by the way, i can’t find the backsticks in my mac. it used to be in older modals next to the 1 key, but now it is not.