Facebook
From Baby Sheep, 3 Years ago, written in Plain Text.
This paste is a reply to Untitled from Crippled Horse - view diff
Embed
Download Paste or View Raw
Hits: 195
  1. var x = [[1, 2],[3, 4],[5, 6]];
  2. var y = [];
  3. var i = 0;
  4.  
  5. while ( i < x[0].length) {
  6.   x.forEach(function(item, index) {
  7.     y[i][index] = x[index][i];
  8.   })
  9.   i++
  10. }
  11.  
  12. console.log(y);