title: Find and replace object in array (based on id)
body: <p>Got a bit of a puzzle here...I want to loop through <code>allItems</code> and return <code>allItems</code> but replace with any <code>newItems</code> that matches its id. How can I look for a match on <code>id</code> and then replace it with the correct object into the array?</p>
  
  <pre><code>const allItems = [
    {
      'id': 1,
      'category_id': 1,
      'text': 'old',
    },
    {
      'id': 2,
      'category_id': 1,
      'text': 'old'
    }
  ]
  
  const newItems = [
    {
      'id': 1,
      'category_id': 1,
      'text': 'new',
      'more_info': 'abcd'
    },
    {
      'id': 2,
      'category_id': 1,
      'text': 'new',
      'more_info': 'abcd'
    }
  ]
  </code></pre>
  
  <p>What I tried so far:</p>
  
  <pre><code>for(let i = 0; i &lt; allItems.length; i++) {
    if(newItems.indexOf(allItems[i].id) &gt; -1){
      allItems[i] = newItems
    }
  }
  </code></pre>
  
  <p>How can I get the position of the object in <code>newItems</code> and then replace it into <code>allItems</code>?</p>