title: array.filter is returning entire object instead of just one value
body: <p>I have a simple function that is filtering an array.</p>
  <p>I only want the string value, not the entire object.</p>
  <p>Why is the entire object coming back and not just the string?</p>
  <p>I get the desired output if I switch the return to a console.log()</p>
  <p>Any ideas?</p>
  <p>Here is the code</p>
  <pre><code> const Array2 = [
          { header: 'First name', HeaderIndex: 0},
          { header: 'Last name', HeaderIndex: 1},
          { header: 'Company', HeaderIndex: 2},
          { header: 'Favorite food', HeaderIndex: 3},
          { header: 'Favorite color', HeaderIndex: 4},
      ]
  
  const testing = Array2.filter((obj) =&gt; { if(obj.HeaderIndex === 1) { return obj.header } } )
  
  console.log(testing)
  
  // gives undesired output
  
  [{…}]
  0: {header: 'Last name', HeaderIndex: 1}
  length: 1
  [[Prototype]]: Array(0)
  
  
  
  const testing = Array2.filter((obj) =&gt; { if(obj.HeaderIndex === 1) { console.log(obj.header)} } )
  
  // gives desired output
  
  &quot;Last name&quot;
  </code></pre>
  <p>my problematic output is below, I just want to return the string</p>
  <pre><code>[{…}]
  0: {header: 'Last name', HeaderIndex: 1}
  length: 1
  [[Prototype]]: Array(0)
  
  </code></pre>
  <p>Update*</p>
  <p>I accepted the answer from Mayur because it solved my problem in a bigger use case.  Here is my bigger use case below where I needed to merge these two arrays depending on Array1 index needing to match HeaderIndex from Array2</p>
  <pre><code>
  
  const Array1 = [ 
      ['Alex', 'Boe', 'MeowWolf', 'pizza', 'pink'],
      ['Arron', 'Coe', 'Kmart', 'tofu', 'purple'],
      ['Jane', 'Doe', 'Sears', 'tacos', 'orange'],
      ['John', 'Eoe', 'YugiOh', 'blueberries', 'magenta'],
      ['Suzie', 'Boe', 'Toyota', 'steroids', 'blue']
      ]
      
      
      const Array2 = [
          { header: 'First name', HeaderIndex: 0},
          { header: 'Last name', HeaderIndex: 1},
          { header: 'Company', HeaderIndex: 2},
          { header: 'Favorite food', HeaderIndex: 3},
          { header: 'Favorite color', HeaderIndex: 4},
      ]
  
  const testResult = Array1.map((arr) =&gt; arr.map((string) =&gt; { return  {&quot;ChosenHeader&quot;: Array2.filter((obj) =&gt; obj.HeaderIndex === arr.indexOf(string))[0]?.header, &quot;content&quot;: string}} ))
  
  console.log(testResult)
  
  
  // desired output
  
  
  [
  
  0: {ChosenHeader: 'First name', content: 'Alex'}
  1: {ChosenHeader: 'Last name', content: 'Boe'}
  2: {ChosenHeader: 'Company', content: 'MeowWolf'}
  3: {ChosenHeader: 'Favorite food', content: 'pizza'}
  4: {ChosenHeader: 'Favorite color', content: 'pink'}
  
  ]
  </code></pre>