How to compare strings in google apps script

前端 未结 4 1552
盖世英雄少女心
盖世英雄少女心 2021-01-13 03:22

I am trying to compare string values that I have obtained from my google spreadsheet.

My Months appear in this format \" Jun13\", \"Aug13\" etc. and my script has tr

4条回答
  •  鱼传尺愫
    2021-01-13 03:56

    try that:

    function test(){
      var ss = SpreadsheetApp.getActive().getSheetByName("month test");
      var data = ss.getRange(2,2,ss.getLastRow(),3).getValues();
      var ListOfMonths = new Array();  
      for(var i in data){
        var row = data[i][0].toString();
        if(ListOfMonths.indexOf(row)==-1){
          Logger.log(row+" is not referenced. Adding it");
          ListOfMonths.push(row);
        }
      }
      Logger.log(ListOfMonths);
    }
    

提交回复
热议问题