title: Concat two arrays with filtering
body: <p>I have two arrays. I need to combine both of them and make a new array which has <code>dayOfWeek</code> 2, 3, 4, 5, 6. Which means priority for the <code>dayOfWeek</code> is in <code>array1</code>. Means need to keep <code>dayOfWeek</code> 3, 4, 5 from <code>array1</code>.</p>
  
  <pre><code>array1 = [
    {dayOfWeek: 2, home1: "01:30"},
    {dayOfWeek: 3, home1: "02:30"},
    {dayOfWeek: 4, home1: "03:30"},
    {dayOfWeek: 5, home1: "04:30"},
  ]
  
  array2 = [
    {dayOfWeek: 3, home1: "05:30"},
    {dayOfWeek: 4, home1: "06:30"},
    {dayOfWeek: 5, home1: "07:30"},
    {dayOfWeek: 6, home1: "08:30"},
  ]
  </code></pre>
  
  <p>Output should be </p>
  
  <pre><code>finalArray = [
    {dayOfWeek: 2, home1: "01:30"},
    {dayOfWeek: 3, home1: "02:30"},
    {dayOfWeek: 4, home1: "03:30"},
    {dayOfWeek: 5, home1: "04:30"},
    {dayOfWeek: 6, home1: "08:30"},
  ]
  </code></pre>
  
  <p>I tried this but it pushes the <code>dayOfWeek</code> from both the arrays. How can I filter them?</p>
  
  <pre><code>const finalArray = []
  array1.map((a) =&gt; {
      array2.map((a2) =&gt; {
          if (a.dayOfWeek === a2.dayOfWeek) {
            finalArray.push(a)
          }
          if (a.dayOfWeek === a2.dayOfWeek) {
            finalArray.push(a2)
          }
      })
  })
  </code></pre>
  
  <p>Thanks in advance!!!</p>