Skip to content

Instantly share code, notes, and snippets.

@CodingBobby
Last active May 12, 2018 16:19
Show Gist options
  • Save CodingBobby/741429970615fc38b413331609fce25e to your computer and use it in GitHub Desktop.
Save CodingBobby/741429970615fc38b413331609fce25e to your computer and use it in GitHub Desktop.
returns array of a matrix collumn's max lengths
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