Skip to content Skip to sidebar Skip to footer

What Is The Simplest Method To Remove Non-0 Falsy Values From Js Array?

I am trying to have a function be able to 'pick up where it left off' in Google Sheets. I need to find the last row in a specific column which has data. However: The sheet has man

Solution 1:

The simplest method to remove all falsy values excelpt zero, you could check for truthy value or for zero.

result = array.filter(v => v || v === 0);

Solution 2:

Finding column height

This is what I do:

functiongetColumnHeight(col,sh,ss){
  var ss=ss || SpreadsheetApp.getActive();
  var sh=sh || ss.getActiveSheet();
  var col=col || sh.getActiveCell().getColumn();
  var rg=sh.getRange(1,col,sh.getLastRow(),1);//This is just a reasonable starting point.var vA=rg.getValues();
  while(vA[vA.length-1][0].length==0){
    vA.splice(vA.length-1,1);
  }
  return vA.length;
}

Post a Comment for "What Is The Simplest Method To Remove Non-0 Falsy Values From Js Array?"