title: How to use map/filter to modify contents of an array of objects?
body: <p>I have the following array:</p>
  <pre><code>myarray = [
      { &quot;key&quot;: &quot;A&quot; },
      { &quot;key&quot;: &quot;B&quot; }
  ]
  </code></pre>
  <p>How can I use a map/filter function in JavaScript to do the equivalent of:</p>
  <pre><code>for (var i = 0; i &lt; myarray.length; i++) {
      if ( myarray[i].key == 'B') {
          myarray[i].mark = &quot;marked!&quot;
      }
  }
  </code></pre>
  <p>In my attempt, I don't get the <code>mark</code> property in the output:</p>
  <pre><code>myarray.filter((someobject) =&gt; someobject.key == 'B').mark = &quot;marked!&quot;
  console.log(myarray) // this does not show the &quot;mark&quot; key.
  </code></pre>
  <p>NB: I want to modify the original array.</p>