title: I want to return a multidimensional array depending on values within nested arrays
body: <p>I'm building a search function in react-native and redux.  In my action creator, I'm returning a json from Firebase.  I then turn json into an array:</p>
  
  <pre><code> const myObj = snapshot.val(); //json 
   const array1 = Object.entries(myObj).map(function(key) {
      return (key);
    });
  </code></pre>
  
  <p>That way I can filter() through array1.</p>
  
  <pre><code>const array2 = array1.filter(
      (value) =&gt; {
        const element = "John Deere"; // I've hard coded the user input 
  
      return (value.indexOf(element) !== -1);
    });
  </code></pre>
  
  <p>However, array1 is a multi-dimensional array.  So, this filter() doesn't have access to the nested array.  If I create an array copy1 like so, it will have access:</p>
  
  <pre><code>  const copy1 = [];
    const len = array1.length;
    for (let i = 0; i &lt; len; i++) {
    copy1.push(array1[i][1]);
    }
  </code></pre>
  
  <p>But then I lose access to </p>
  
  <pre><code>array1[i][0]. 
  </code></pre>
  
  <p>That index is a unique id created by Firebase. Which I need to make sure my data doesn't get all mixed up.  </p>
  
  <p>Is there a way to .filter() a specific index of an array (array1[i][1]), but to return the full array where that specific index matches the criteria?</p>
  
  <pre><code>(array1 [i] where array1 [i][1] matches the user input(element))
  </code></pre>
  
  <p>I can't just return:</p>
  
  <pre><code>array1 [i][j]
  </code></pre>
  
  <p>because array1 [i][0] is just a string and not an object (key value pair), so that causes an error.  </p>
  
  <p>Any help is much appreciated!</p>