Can someone explain why the line Logger.log("%s EQUALS %s",col1[i],col2[i]);
is never called? Im new to Javascript, but based on this SO post I am using the correct operator for comparison in the if
statement. The values are guaranteed to be either integers, or an empty cell if that makes a difference.
function SetFilter(){
var first_row_to_hide=4;
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var maxrows=sheet.getMaxRows();
col1 = sheet.getRange(first_row_to_hide,3,maxrows,1).getValues();//getRange(row, column, numRows, numColumns) -- column: C
col2 = sheet.getRange(first_row_to_hide,4,maxrows,1).getValues();//column: D
for (var i = 1; i < col1.length; i++){
Logger.log("%s ? %s",col1[i],col2[i]);
if (col1[i] === col2[i]){
Logger.log("%s EQUALS %s",col1[i],col2[i]);
}//sheet.hideRows(i+first_row_to_hide);
}
Logger.log("DONE");
}
example values in column1 and 2:
col1 col2 Log output of '%s ? %s'
1 2 [1.0] ? [2.0]
1 1 [1.0] ? [1.0]
0 0 [0.0] ? [0.0]
0 1 [0.0] ? [0.0]
4 5 [4.0] ? [5.0]