Question: I am just learning javascript.I am pretty confused with manipulating multidimensional arrays.

```
var myarr = [ 
       [ 7, 9, 10 ], 
       [ 6, 9 ], 
       [ 5, 9 ] 
  ]

```

I want to insert zero like this.What is the smart way to do this in javascript

```
       [ 
           [ 7, 9, 10 ], 
           [ 6, 9, 0 ], 
           [ 5, 9, 0 ] 
       ]

```

Answer: 
```
var maxLength=0;
for(var i=0;i<myarr.length;i++){
   if(myarr[i].length>maxLength){
      maxLength=myarr[i].length
  }
}
for(var i=0;i<myarr.length;i++){
    if(myarr[i].length!=maxLength){
    fillZeros(myarr[i])
    }
  }
function fillZeros(child){
    while(child.length!=maxLength)
     {child.push(0);}
}

```
using map function

```
var arr = [ 
           [ 7, 9, 10 ], 
           [ 6, 9], 
           [ 5, 9] 
       ]

       var arr1 = arr.map(function(e){
       var arr2 = [];
        if(e.length < 3)
            e.push(0);

         arr2.push(e);
         return arr2;

       });

      alert(arr1);

```