Remove duplicates values in array Google Apps Script

前端 未结 2 987
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 15:29

I would like to know how to remove duplicates values from 2 arrays, combined into one main array.

This values must NOT be removed from the sheets or document, just i

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 15:46

    In your code you are not doing anything to filter the duplicate values. This line will just sort the data and won't give you unique data.

    var uniqueData = allData.sort(); 
    

    You can do something like this on your merged array, after you 'installing' 2DArray lib: https://sites.google.com/site/scriptsexamples/custom-methods/2d-arrays-library

    var uniqueData = unique(allData);
    

    Another option is to create a loop and check for duplicate values, but you should remember to transform all the values of the string to lowercase before you do these matches.

提交回复
热议问题