Last active
May 12, 2018 16:19
-
-
Save CodingBobby/741429970615fc38b413331609fce25e to your computer and use it in GitHub Desktop.
returns array of a matrix collumn's max lengths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function colMax(mrx) { | |
let mLen = []; | |
let len = 0, lVal = true; | |
for(var m=0; m<mrx[0].length; m++) { | |
for(var n in mrx) { | |
let eLen = mrx[n][m].toString().length; | |
lVal = eLen ? lVal<eLen : lVal; | |
if(len<eLen) | |
len = eLen; | |
} | |
mLen.push(len); | |
len -= len; | |
lVal = true; | |
} | |
return mLen; | |
} | |
// push lVal in <line 11> instead to get booleans of wheather the length in- or decreased |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment