title: update array of object without mutation
body: <p>I'm following a react tutorial but I'm lost. I don't understand starting line 9.</p>
  
  <p><a href="https://i.stack.imgur.com/wSqZ6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wSqZ6.png" alt="enter image description here"></a></p>
  
  <p>so I tried to make a little miarature </p>
  
  <pre><code>const updateTodo = (list, updated) =&gt; {
     const index = list.findIndex(item =&gt; item.id === updated.id)
     return [
     ...list.slice(0,index),
     updated,
     ...list.slice(index+1)
     ]
  }
  </code></pre>
  
  <p><a href="https://jsbin.com/sifihocija/2/edit?js,console" rel="noreferrer">https://jsbin.com/sifihocija/2/edit?js,console</a> but failed to produce the result that the author did, what's wrong?</p>