I have an array in maxtrix form like this
var costs = [
[4, 6, 8, 8],
[6, 8, 6, 7],
[5, 7, 6, 8],
];
how do i transform it to this
[[4,6,5], [6,8,7], [8,6,5], [8,7,5]]
This is what am trying
var cols = [];
for(var i = 0; i<costs.length; i++)
{
cols.push(costs[i][0]);
}
return col;
And this gives me [4,6,5]. I know am missing something, any help will be great. Thanks