title: Compare array items (items are arrays) if items in same position are equals
body: <p><strong>I'm using Adobe ExtendScript Toolkit to debug. I'm coding for InDesign and really don't have deep JavaScript knowledge (and don't know what ES6 means).
  ExtendScript doesn't accept let as reserved word. Maybe something about this ES6 you're meaning?</strong></p>
  
  <p>I need to compare all the items in an array and join some of them if one of its child are the same. Let me explain:</p>
  
  <p>Based on the following array:</p>
  
  <pre><code>var array = [[1,"luis"] , [2,"felipe"] , [2,"erick"] , [2,"mark"] , [3,"dustin"]]
  </code></pre>
  
  <p>So, I want to get as result this array:</p>
  
  <pre><code>var array = [[1,"luis"] , [2,"felipe; erick; mark"] , [3,"dustin"]]
  </code></pre>
  
  <p>How can I compare the array items to get the desired result?</p>
  
  <p>I already tried two for loops and a while.
  Maybe I made them wrong. Because of that, I'm here to ask you guys.</p>
  
  <p>If I use this:</p>
  
  <pre><code>for (var i=0; i&lt;array.length-1; i++) {
      for (var j=i+1; j&lt;array.length; j++) {
          if (array[i][0] == array[j][0]) {
              array[i][1] = array[i][1] + "; " + array[j][1];
              }
          }
      }
  </code></pre>
  
  <p>I have all results. Like this:</p>
  
  <pre><code>1,luis
  2,felipe; erick; mark
  2,erick; mark
  2,mark
  3,dustin
  </code></pre>