I have an array object like this
      dta: [
        {
           amt: "200000",
           dat: "2016-10-14 10:41:20 am",
           grt: "GRT",
           uid:"example123"
        },
        {
           amt: "300000",
           dat: "2016-10-14 10:41:20 am",
           grt: "RPD",
           uid:"example123"
        }]
and I wish to split this array in two arrays based on the based on the grt:
I tried this but it starts the secong array index from 1.
function seperate(data) {
console.log(data)
for (var i = 0; i < data.dta.length; i++) {
       if (data.dta[i].grt === 'GRT') {
            owing[i] = data.dta[i];
       } else {
            repaid[i] = data.dta[i];
       }
   }
}
 
     
    