I'm trying to create a script to check if all the values in a range of rows are unique usig google app scripts.
function verficarCodUnico(){
let ss = SpreadsheetApp.getActive();
let sheet = ss.getActiveSheet();
let lastRow = sheet.getMaxRows();
let frozenRows = sheet.getFrozenRows();
let fCol = sheet.getRange(frozenRows+1,1,lastRow).getValues();
//this range created with to more lines than it should, so:
fCol.length = fCol.length -2;
let repeated = [];
let aux = fCol.filter(function(elemento, i) {
if(fCol.indexOf(elemento) !== i) {
repeated.push(elemento)
}
return fCol.indexOf(elemento) == i;
this code should work but the fCol array is been created as a array of arrays
fCol = [[1],[123],[2],[123]]
but what i want is fCol = [1,123,2,123]
I could fix the problem with
let fCol2 = [];
for (i in fCol){fCol2.push(fCol[i][0])}
I looked in the google app script api, and i undestood that getValues should return the values of the range. Or I am wrong?