title: Save multiple objects on Local Storage? Javascript
body: <p>I have 2 rooms <code>{roomId: room1, roomId: room2}</code> and I want to save Object for  each rooms on localStorage.</p>
  <p>The object looks like</p>
  <pre><code>let notifiedRoom = {
      roomId: roomId,
      dismissed: true
  }; 
  </code></pre>
  <p>The notifiedRoom Object is saved on localStorage when the user closes notification for respective room.</p>
  <pre><code>
  import React from 'react';
  import { toast } from 'react-toastify';
  
  
  const RoomNotification = (props) =&gt; {
  
    const { roomId, message } = props;
  
    const setLocalStorage = (roomId) =&gt; {
      let notifiedRoom = {
          roomId: roomId,
          dismissed: true
         }; 
      localStorage.setItem('notifiedRoom', JSON.stringify(notifiedRoom));
    };
  
    const notify = () =&gt; {
      toast(&lt;div&gt;&lt;p&gt;{roomId}&lt;/p&gt;&lt;p&gt;{message}&lt;/p&gt;&lt;/div&gt;,
          {
              toastId: roomId,
              position: &quot;top-center&quot;,
              draggable: true,
              onClose:() =&gt; setLocalStorage(roomId)
          });
     };
  
  }
  </code></pre>
  <p>the problem I have is this will only save a object for a room at a time. So if you close room1 Notification then on localStorage
  there is <code>roomId: room01, dismissed: true</code>, if I close room2 Notification then the previous localStorage object for room1 is overwritten by room2.</p>
  <p>I only need it to overwrite if the roomId matches. Else just create new object for every different roomId on locatStorage.</p>
  <p>Many thanks</p>