title: Merging two array of objects only when array element contains error
body: <p>So I have two arrays with objects. And also an array indicating where the replacement should take place(It spots if object contains error)</p>
  <pre><code>         const oldData = [
      {
          &quot;index&quot;: &quot;01&quot;,
          &quot;skuId&quot;: &quot;Sarbb-033&quot;,
          &quot;name&quot;: &quot;Sasko Black&quot;,
          &quot;barcode&quot;: &quot;843331510012&quot;,
          &quot;description&quot;: &quot;Nice black bread&quot;,
          &quot;brand&quot;: &quot;ERROR: No brand matching: Sasko&quot;,
          &quot;productLine&quot;: &quot;ERROR: No product line matching: line&quot;,
          &quot;inputType&quot;: &quot;Weight&quot;,
          &quot;uom&quot;: &quot;ERROR: Invalid UoM type, valid values are: kg,g,mg,kl,l,ml,m,cm,mm&quot;,
          &quot;value&quot;: &quot;700&quot;,
          &quot;capacity&quot;: &quot;1&quot;,
          &quot;image&quot;: &quot;&quot;
      },
      {
          &quot;index&quot;: &quot;02&quot;,
          &quot;skuId&quot;: &quot;ERROR: Empty sku_id is not allowed&quot;,
          &quot;name&quot;: &quot;Sasko Black1&quot;,
          &quot;barcode&quot;: &quot;ERROR: Empty barcode is not allowed&quot;,
          &quot;description&quot;: &quot;Nice black bread&quot;,
          &quot;brand&quot;: &quot;ERROR: No brand matching: Future Life&quot;,
          &quot;productLine&quot;: &quot;ERROR: No product line matching: line&quot;,
          &quot;inputType&quot;: &quot;Weight&quot;,
          &quot;uom&quot;: &quot;kg&quot;,
          &quot;value&quot;: &quot;701&quot;,
          &quot;capacity&quot;: &quot;2&quot;,
          &quot;image&quot;: &quot;&quot;
      },
      {
          &quot;index&quot;: &quot;03&quot;,
          &quot;skuId&quot;: &quot;Sarbb-099&quot;,
          &quot;name&quot;: &quot;Sasko Black100&quot;,
          &quot;barcode&quot;: &quot;843332555614&quot;,
          &quot;description&quot;: &quot;Nice black bread&quot;,
          &quot;brand&quot;: &quot;fwfwf&quot;,
          &quot;productLine&quot;: &quot;naam&quot;,
          &quot;inputType&quot;: &quot;weight&quot;,
          &quot;uom&quot;: &quot;g&quot;,
          &quot;value&quot;: &quot;702&quot;,
          &quot;capacity&quot;: &quot;3&quot;,
          &quot;image&quot;: &quot;&quot;
      },
      {
          &quot;index&quot;: &quot;04&quot;,
          &quot;skuId&quot;: &quot;Sarbb-100&quot;,
          &quot;name&quot;: &quot;Sasko Black101&quot;,
          &quot;barcode&quot;: &quot;ERROR: Empty barcode is not allowed&quot;,
          &quot;description&quot;: &quot;ERROR: Invalid description: [] it should not be blank.&quot;,
          &quot;brand&quot;: &quot;fwfwf&quot;,
          &quot;productLine&quot;: &quot;fwfwf&quot;,
          &quot;inputType&quot;: &quot;Weight&quot;,
          &quot;uom&quot;: &quot;g&quot;,
          &quot;value&quot;: &quot;703&quot;,
          &quot;capacity&quot;: &quot;4&quot;,
          &quot;image&quot;: &quot;&quot;
      },
      {
          &quot;index&quot;: &quot;05&quot;,
          &quot;skuId&quot;: &quot;Sarbb-101&quot;,
          &quot;name&quot;: &quot;Sasko Black102&quot;,
          &quot;barcode&quot;: &quot;843332555616&quot;,
          &quot;description&quot;: &quot;Nice black bread&quot;,
          &quot;brand&quot;: &quot;fwfwf&quot;,
          &quot;productLine&quot;: &quot;naam&quot;,
          &quot;inputType&quot;: &quot;weight&quot;,
          &quot;uom&quot;: &quot;g&quot;,
          &quot;value&quot;: &quot;704&quot;,
          &quot;capacity&quot;: &quot;5&quot;,
          &quot;image&quot;: &quot;&quot;
      }
  ]
  
  
      const newData = [
      {
          &quot;index&quot;: &quot;01&quot;,
          &quot;skuId&quot;: &quot;Sarbb-033&quot;,
          &quot;name&quot;: &quot;Sasko Black&quot;,
          &quot;barcode&quot;: &quot;843331510012&quot;,
          &quot;description&quot;: &quot;Nice black bread&quot;,
          &quot;brand&quot;: &quot;fwfwf&quot;,
          &quot;productLine&quot;: &quot;fwfwf&quot;,
          &quot;inputType&quot;: &quot;Weight&quot;,
          &quot;uom&quot;: &quot;g&quot;,
          &quot;value&quot;: &quot;700&quot;,
          &quot;capacity&quot;: &quot;1&quot;,
          &quot;image&quot;: &quot;&quot;
      },
      {
          &quot;index&quot;: &quot;02&quot;,
          &quot;skuId&quot;: &quot;sarb&quot;,
          &quot;name&quot;: &quot;Sasko Black1&quot;,
          &quot;barcode&quot;: &quot;124125125&quot;,
          &quot;description&quot;: &quot;Nice black bread&quot;,
          &quot;brand&quot;: &quot;fwfwf&quot;,
          &quot;productLine&quot;: &quot;fwfwf&quot;,
          &quot;inputType&quot;: &quot;Weight&quot;,
          &quot;uom&quot;: &quot;kg&quot;,
          &quot;value&quot;: &quot;701&quot;,
          &quot;capacity&quot;: &quot;2&quot;,
          &quot;image&quot;: &quot;&quot;
      },
      {
          &quot;index&quot;: &quot;03&quot;,
          &quot;skuId&quot;: &quot;Sarbb-100&quot;,
          &quot;name&quot;: &quot;Sasko Black101&quot;,
          &quot;barcode&quot;: &quot;214214214&quot;,
          &quot;description&quot;: &quot;Desc&quot;,
          &quot;brand&quot;: &quot;fwfwf&quot;,
          &quot;productLine&quot;: &quot;fwfwf&quot;,
          &quot;inputType&quot;: &quot;Weight&quot;,
          &quot;uom&quot;: &quot;g&quot;,
          &quot;value&quot;: &quot;703&quot;,
          &quot;capacity&quot;: &quot;4&quot;,
          &quot;image&quot;: &quot;&quot;
      }
  ]
  
      const errorRows = [0,1,3]
  
  
        const myTerribleAttempt = oldTableData.map((oldData, rowIndex) =&gt; {
    return errorRows.map(index =&gt; {
      if(rowIndex === index){
       newTableData.map(newData =&gt; {
  oldData = newData
       })
      }
    })
   })
  </code></pre>
  <p>I have tried multiple maps and just can't seem to get the right result. The new data objects should replace old data objects at the object containing the error. Please give me some assistance.</p>