title: Find and Update in nested array of objects in javascript
body: <p>Here is the array of array's</p>
  <pre><code>      let A = {
          &quot;profileId&quot;: &quot;12345&quot;,
          &quot;data&quot;: [{
                  &quot;profileId&quot;: &quot;12345&quot;,
                  &quot;campaignId&quot;: &quot;39641&quot;,
                  &quot;portfolioData&quot;: {
                      &quot;portfolioData&quot;: [{
                          &quot;asin&quot;: &quot;B08FSSHG17ZH&quot;,
                          &quot;sku&quot;: [&quot;130511&quot;]
                      }, {
                          &quot;asin&quot;: &quot;B0OH8FHF74TB&quot;,
                          &quot;sku&quot;: [&quot;130512&quot;]
                      }, {
                          &quot;asin&quot;: &quot;B0ZP8FHBWP89&quot;,
                          &quot;sku&quot;: [&quot;130513&quot;]
                      }]
                  }
              },
              {
                  &quot;profileId&quot;: &quot;12345&quot;,
                  &quot;campaignId&quot;: &quot;35551&quot;,
                  &quot;portfolioData&quot;: {
                      &quot;portfolioData&quot;: [{
                          &quot;asin&quot;: &quot;B08FSSHG17ZH&quot;,
                          &quot;sku&quot;: [&quot;130511&quot;]
                      }, {
                          &quot;asin&quot;: &quot;B0OH8FHF74TB&quot;,
                          &quot;sku&quot;: [&quot;130512&quot;]
                      }, {
                          &quot;asin&quot;: &quot;B0ZP8FHBWP89&quot;,
                          &quot;sku&quot;: [&quot;130513&quot;]
                      }]
                  }
              }
      
          ]
      }
  
      let B = [{
          asin: 'B08FSSHG17ZH',
          sku: '130523221'
      },
      {
          asin: 'B0OH8FHF74TB',
          sku: '132122182'
      }
  ]
  </code></pre>
  <p>So i want to take array B and search the value with the help of asin in array A and update the sku in array. So the expected output i am looking for is:-</p>
  <pre><code>{
      &quot;profileId&quot;: &quot;12345&quot;,
      &quot;data&quot;: [{
              &quot;profileId&quot;: &quot;12345&quot;,
              &quot;campaignId&quot;: &quot;39641&quot;,
              &quot;portfolioData&quot;: {
                  &quot;portfolioData&quot;: [{
                      &quot;asin&quot;: &quot;B08FSSHG17ZH&quot;,
                      &quot;sku&quot;: [&quot;130511&quot;, &quot;130523221&quot;]
                  }, {
                      &quot;asin&quot;: &quot;B0OH8FHF74TB&quot;,
                      &quot;sku&quot;: [&quot;130512&quot;, &quot;132122182&quot;]
                  }, {
                      &quot;asin&quot;: &quot;B0ZP8FHBWP89&quot;,
                      &quot;sku&quot;: [&quot;130513&quot;]
                  }]
              }
          },
          {
              &quot;profileId&quot;: &quot;12345&quot;,
              &quot;campaignId&quot;: &quot;35551&quot;,
              &quot;portfolioData&quot;: {
                  &quot;portfolioData&quot;: [{
                      &quot;asin&quot;: &quot;B08FSSHG17ZH&quot;,
                      &quot;sku&quot;: [&quot;130511&quot;, &quot;130523221&quot;]
                  }, {
                      &quot;asin&quot;: &quot;B0OH8FHF74TB&quot;,
                      &quot;sku&quot;: [&quot;130512&quot;, &quot;132122182&quot;]
                  }, {
                      &quot;asin&quot;: &quot;B0ZP8FHBWP89&quot;,
                      &quot;sku&quot;: [&quot;130513&quot;]
                  }]
              }
          }
  
      ]
  }
  </code></pre>
  <p>I am trying to push new value in the sku array which is inside of array of array.
  So i am trying to update with the function like:-</p>
  <pre><code> function update(columns, responseData) {
            const helper = new Map();
            for (const item of responseData) helper.set(item.asin, item);
  
            for (const item of columns) {
              const s = helper.get(item.asin);
              item.sku.push(item.sku);
            }
          }
  
  update(A, B);
  </code></pre>
  <p>I know this function wont execute as it is array of array of objects.
  Where as the function i have written is for array of objects.</p>