title: Updating objects of array in array with array of Object
body: <p>I have a two javaScript Array</p>
  <pre><code>let x = [
      {
          id: 'Abc',
          children: [
              {
                  id: 12,
                  name: 'john'
              }, {
                  id: 13,
                  name: 'dow'
              }
          ]
      }, {
          id: 'xyz',
          children: [
              {
                  id: 123,
                  name: 'jack'
              }, {
                  id: 134,
                  name: 'abc'
              }
          ]
      }
  ]
  let y = [
      {
          id: 12,
          name: 'mac'
      }, {
          id: 13,
          name: 'dow'
      }, {
          id: 123,
          name: 'Tom'
      }, {
          id: 134,
          name: 'abc'
      }
  ]
  </code></pre>
  <p>I want to update my <code>x</code> with <code>y</code> having updated array like this</p>
  <pre><code>[
      {
          id: 'Abc',
          children: [
              {
                  id: 12,
                  name: 'mac'
              }, {
                  id: 13,
                  name: 'dow'
              }
          ]
      }, {
          id: 'xyz',
          children: [
              {
                  id: 123,
                  name: 'Tom'
              }, {
                  id: 134,
                  name: 'abc'
              }
          ]
      }
  ]
  </code></pre>
  <p>I tried this <a href="https://stackoverflow.com/a/37585362/3026578">solution</a> like this</p>
  <pre><code>x.map((a, index)=&gt;{
      a.children.map((b, i)=&gt;{
          // console.log('update')
          y.find(o =&gt; o.id === b.id) || b;
      })
  })
  </code></pre>
  <p>but I am having <code>undefined</code>.  I searched many answer but didn't get any luck.</p>