title: Filtering a two dimensional array in apps script
body: <p>In apps script I have the following:</p>
  
  <pre><code>function diff(A, B) {
    return A.filter(function (a) {
      return B.indexOf(a) == -1;
    });
  }
  </code></pre>
  
  <p>When I run:</p>
  
  <pre><code>function testArray(){
  
    ta = ['a','b','c','d']
    ts = ['a','b','c']
  
    o =diff(ta,ts)
  
    Logger.log(o);
  
  
  }
  </code></pre>
  
  <p>I get: ['d'] - The correct answer , now I'm trying to apply filter to a 2d array of values - a google sheet.</p>
  
  <p>I tried :</p>
  
  <pre><code>  var ss = SpreadsheetApp.getActiveSpreadsheet();
    var target_sheet_range =   ss.getSheets()[1].getDataRange();
    var target_sheet_values =   target_sheet_range.getValues();
          Logger.log('target_sheet_values');
            Logger.log(target_sheet_values);
    var range = ss.getSheets()[0].getDataRange();
    var values = range.getValues();
  
  
            Logger.log('values');
            Logger.log(values);
  
  
      var diff_values = diff(values, target_sheet_values)
  </code></pre>
  
  <p>but this is not taking account the 2d nature of the arrays. You can see it at  google spreadsheet <a href="https://docs.google.com/spreadsheets/d/1fFr9Sz2EAiMYoybg-evV33n_BZjF-1QNnnKqiqSXQ_g/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1fFr9Sz2EAiMYoybg-evV33n_BZjF-1QNnnKqiqSXQ_g/edit?usp=sharing</a></p>
  
  <p>output:</p>
  
  <pre><code>[18-06-23 14:45:22:129 EDT] target_sheet_values
  [18-06-23 14:45:22:130 EDT] [[a, a, a, a, a], [z, x, c, v, b], [m, n, b, v, c]]
  [18-06-23 14:45:22:457 EDT] values
  [18-06-23 14:45:22:458 EDT] [[a, a, a, a, a], [z, x, c, v, b], [m, n, b, v, c], [a, s, d, f, g], [q, w, e, r, t]]
  [18-06-23 14:45:22:459 EDT] hhhhhh
  [18-06-23 14:45:22:459 EDT] [[a, a, a, a, a], [z, x, c, v, b], [m, n, b, v, c], [a, s, d, f, g], [q, w, e, r, t]]
  </code></pre>
  
  <p>How do I modify the filter function 2 filter a 2d array</p>