multidimensional array JAVASCRIPT something wrong -


hey guys need soe please :p

what's wrong code?

var arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; var narr = []; // want [[1, 4, 7], [2, 5, 8], [3, 6, 9]]  function arange(mass) {     (var = 0; < mass.length; i++) {         (var j = 0; j < mass[i].length; j++) {             narr[mass[i]].push(mass[j][i]);         }     } } 

if call function there problem : "typeerror: cannot read property 'push' of undefined." thank you. link here

or use es6 1 liner

var arr = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ];        var res = arr.map((e, i) => e.map((_, j) => arr[j][i]));    document.write(json.stringify(res));


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -