title: How do i replace a value in an object with another updated value in an object if the id matches?
body: <p>Currently, I am storing genre in the reducer.</p>
  <pre><code>const genre = {
      &quot;0&quot;: {
          &quot;id&quot;: 1912,
          &quot;title&quot;: &quot;Fiction&quot;,
          &quot;name&quot;: &quot;Greg&quot;
      },
      &quot;1&quot;: {
          &quot;id&quot;: 1957,
          &quot;title&quot;: &quot;Non-Fiction&quot;,
          &quot;name&quot;: &quot;John&quot;
      },
      &quot;2&quot;: {
          &quot;id&quot;: 1958,
          &quot;title&quot;: &quot;Literature&quot;,
          &quot;name&quot;: &quot;James&quot;
      },
  }
  </code></pre>
  <p>How do i check if the <strong>id in updatedGenre</strong> matches the <strong>id in genre</strong>, then i would update the <strong>title or name</strong> in genre with the updated <strong>title or name</strong> based on the id.</p>
  <pre><code>const updatedGenre = {
      &quot;id&quot;: 1958,
      &quot;title&quot;: &quot;Literature &amp; Poems&quot;,
      &quot;name&quot;: &quot;Leo&quot;
  }
  </code></pre>
  <p>Sample Output: (Example id: 1958)</p>
  <pre><code>const genre = {
      &quot;0&quot;: {
          &quot;id&quot;: 1912,
          &quot;title&quot;: &quot;Fiction&quot;,
          &quot;name&quot;: &quot;Greg&quot;
      },
      &quot;1&quot;: {
          &quot;id&quot;: 1957,
          &quot;title&quot;: &quot;Non-Fiction&quot;,
          &quot;name&quot;: &quot;John&quot;
      },
      &quot;2&quot;: {
          &quot;id&quot;: 1958,
          &quot;title&quot;: &quot;Literature &amp; Poems&quot;,
          &quot;name&quot;: &quot;Leo&quot;
      },
  }
  </code></pre>