title: Javascript Multidimensional Array into single arrays
body: <p>I am a JS newbie and having a hard time figuring out how to run a function with what I have..  </p>
  
  <p>The function:</p>
  
  <pre><code>function compressArray(original) {
  
      var compressed = [];
      // make a copy of the input array
      var copy = original.slice(0);
  
      // first loop goes over every element
      for (var i = 0; i &lt; original.length; i++) {
  
          var myCount = 0;    
          // loop over every element in the copy and see if it's the same
          for (var w = 0; w &lt; copy.length; w++) {
              if (original[i] == copy[w]) {
                  // increase amount of times duplicate is found
                  myCount++;
                  // sets item to undefined
                  delete copy[w];
              }
          }
  
          if (myCount &gt; 0) {
              var a = new Object();
              a.value = original[i];
              a.count = myCount;
              compressed.push(a);
          }
      }
  
      return compressed;
  };
  </code></pre>
  
  <p>I have a multidimensional array like below that I want to pull out the third element to run through the function. </p>
  
  <pre><code>var animalcount = [
          [2.8, 20, "dog, cat, bird, dog, dog"],
          [4.2, 22, "hippo, panda, giraffe, panda"],
          [3.7, 41, "snake, alligator, tiger, tiger"]
                  ];
  </code></pre>
  
  <p>So I'm trying to figure out how to get the array to be single arrays like below</p>
  
  <pre><code>var newArray1 = ("dog", "cat", "bird", "dog", dog");
  var newArray2 = ("hippo", "panda", "giraffe", "panda");
  </code></pre>
  
  <p>or ideally tweak the function so that the multidimensional array can stay in tact.</p>