title: Why does my spread operator show this behaviour?
body: <pre><code>let schools = [
  { name: "Yorktown"},
  { name: "Stratford" },
  { name: "Washington &amp; Lee"},
  { name: "Wakefield"}
  ]
  
  let updatedSchools = editName("Stratford", "HB Woodlawn", schools)
  console.log( updatedSchools[1] ) // { name: "HB Woodlawn" }
  
  
      const editName = (oldName, name, arr) =&gt;
        arr.map(item =&gt; {
          if (item.name === oldName) {
            // what is happening below!?
            return {
              ...item,
              name
            }
          } else {
            return item
          }
        })
  </code></pre>
  
  <p>first of all, i'm sorry if this question might be easy for you, but i'm having trouble understanding how the return statement of the snippet works and would really appreciate help.</p>
  
  <pre><code>return { ...item, name }
  </code></pre>
  
  <p>So i would expect <code>updatedSchool</code> to be (even though it's invalid syntax):  </p>
  
  <pre><code>[
    {name: "Yorktown"},
    { name: "Yorktown", "HB Woodlawn"},  
    { name: "Washington &amp; Lee"},  
    { name: "Wakefield"}  
  ]
  </code></pre>
  
  <p>why does it produce <code>{ name: "HB Woodlawn" }</code>?</p>