title: Filter array and return object by unique ID and get First and Last Index
body: <p>I have an array Like this:</p>
  <pre><code>[{
      &quot;res&quot;: [ '123', 'One', '20210318' ]
  }, {
      &quot;res&quot;: [ '123', 'One', '20210319' ]
  }, {
      &quot;res&quot;: [ '123', 'One', '20210320' ]
  }, {
      &quot;res&quot;: [ '123', 'One', '20210321' ]
  },{
      &quot;res&quot;: [ '456', 'Two', '20210401' ]
  },{
      &quot;res&quot;: [ '456', 'Two', '20210402' ]
  },{
      &quot;res&quot;: [ '456', 'Two', '20210403' ]
  },{
      &quot;res&quot;: [ '456', 'Two', '20210404' ]
  }]
  </code></pre>
  <p>I am trying to get</p>
  <pre><code>[{ 
      &quot;res&quot;: [ '123', 'One', '20210318' ]
   }, {
      &quot;res&quot;: [ '123', 'One', '20210321' ]
   },{
      &quot;res&quot;: [ '456', 'Two', '20210401' ]
      },{
      &quot;res&quot;: [ '456', 'Two', '20210404' ]
  }]
  </code></pre>
  <p>which &quot;One&quot; has the first unique value &quot;20210318&quot; and last index unique value &quot;20210321&quot;
  and &quot;Two&quot; which has the first unique value &quot;20210401&quot; and last index unique value &quot;20210404&quot;</p>
  <p>I have just managed to filter the array by their unique IDs
  and I'm getting only the two results which is the first unique &quot;One&quot; and first unique &quot;Two&quot;</p>
  <pre><code>  const getFilteredArray = array.filter((v,i,a)=&gt; {
  
      const getFilter = a.findIndex( t =&gt; {
        return t.res[0] === v.res[0]
      }) === i;
  
      return getFilter;
    })
  </code></pre>