I'm tryin to convert the column to the row :
var input = [
["aaa","111","zzz"],
["bbb","222","xxx"],
["ccc","333","yyy"]
];
to this :
input = [
["aaa","bbb","ccc"],
["111","222","333"],
["zzz","xxx","yyy"],
];
here what i have done, why the output[j].push(input [i][j]); didnt work ?, the output[j] is all I need ... 'j' is looping right ? I did manual, it works , I did all the research but my brain not good enough yet, so can anyone explain it ?? im a total newbie. I need someone to find my mistake since I always thinkin if my logic actually true but why it'snot workin . it make me confused and not able to learn another way.
function dataHandling(){
var output = [];
for (var i=0; i < input.length ; i++){
output.push([]);
//console.log(i)
for (var j =0; j < input[i].length ; j++){
output[j].push(input[i][j]);
}
}
console.log(output);
}
// console.log(len2);
var input = [
["aaa","111","zzz"],
["bbb","222","xxx"],
["ccc","333","yyy"]
];
dataHandling(input);
EDIT : can this apply without passing the parameter ? and keep dataHandling() empty, but thanks for the that answers tho, im tryin to learn it.
EDIT 2 : meanwhile >> output[i].push(input[j][i]); givin me the answer, yeah it's work but if I change unsymmetric matrix if I change the input to:
var input = [
["0001", "Roman Alamsyah", "Bandar Lampung", "21/05/1989", "Membaca"],
["0002", "Dika Sembiring", "Medan", "10/10/1992", "Bermain Gitar"],
["0003", "Winona", "Ambon", "25/12/1965", "Memasak"],
["0004", "Bintang Senjaya", "Martapura", "6/4/1970", "Berkebun"]
];
why it's not workin at all ? error in jsbin.