title: Javascript: Finding shared values across multiple array
body: <p>What this should be able to do is take in a 2D array filled with one letter values and return an array of all the shared values. This is what I have so far:</p>
  
  <pre><code>var res = array[0].filter(function(x){
          return array.every(function(y){
               return y.indexOf(x) &gt;= 0
          })
      });
  return res;  
  </code></pre>
  
  <p>This is in some form of working state but only under certain condition which makes it very hit and miss. 
  Working as intended:</p>
  
  <pre><code>var array = [["x","x"],
               ["x","x","x"]];
  </code></pre>
  
  <p>This returns the expected array of ["x","x"] but when like this:</p>
  
  <pre><code>var array = [["x","x","x"],
               ["x","x"]];
  </code></pre>
  
  <p>It returns ["x","x","x"]</p>
  
  <p>As you can see the two arrays only share 2 common x's but the code doesn't reflect that in different situations. Also it should be able to handle arrays with other letters like so:</p>
  
  <pre><code>var array = [["x","x","z","y","y"],
               ["x,"x","x","y"],
               ["x","x","z","y"]];
  </code></pre>
  
  <p>With something like this it should return ["x","x","y"] as all arrays share 2 common x's and 1 common y</p>