I have a problem with removing empty arrays/objects from a multidimensional array for my search app in google sheets. I am using getLastRow
so I thought I will avoid this problem but unfortunately it is not.
My array looks like this:
[[1.39080000912E11, RSSMA004025, ボタンキャップ M4X25, 4.0, 4.2, , , ], [1.39080000912E11, RWJAA058068, FTB-268, 1.0, 486.0, 486.0, , ], [, , , , , , , ], [, , , , , , , ]]
And I am looking for something that will delete empty arrays from the end of the array so it should be like this:
[[1.39080000912E11, RSSMA004025, ボタンキャップ M4X25, 4.0, 4.2, , , ], [1.39080000912E11, RWJAA058068, FTB-268, 1.0, 486.0, 486.0, , ]]
It is just a part of the whole array but I hope you will understand what I am looking for.
My code so far:
function getDataForSearch(){
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("WP");
var test1 = ws.getRange(4, 6, ws.getLastRow(),8).getValues();
const arrFiltered = test1.filter(function(x){
return (x !== (undefined || null || ''));
});
Logger.log(arrFiltered);
}