title: Save Local Storage Javscript Check
body: <p>So I have a list of hotel data, and if you click on it the color of the box becomes red. The problem is, how to save the results of the box that has been clicked (turned red) in Local Storage.</p>
  <p><a href="https://i.stack.imgur.com/sGkyE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sGkyE.png" alt="enter image description here" /></a></p>
  <pre class="lang-html prettyprint-override"><code>&lt;script&gt;
      let rooms = 0;
      if (typeof(Storage) !== &quot;undefined&quot;)
          console.log(&quot;Local Storage Available&quot;);
      else
          console.log(&quot;Opps.. No have Local Storage&quot;)
          
      function syncLocalStorage(activity, item, status) {
          switch (activity) {
              case 'ADD':
                  break;
              case 'UPDATE':
                  break;
              case 'DELETE':
                  break;
              default:
                  break;
          }
      }
          
      function spawnGate(gateName, roomCount) {
          const tpl = Array.from({
              length: roomCount
          }, (_, i) =&gt; i + 1).map(xx =&gt; {
              return `&lt;div class=&quot;room&quot; onclick=&quot;reserved(this, ${xx + rooms})&quot;&gt;&lt;span&gt;${xx + rooms}&lt;/span&gt;&lt;/div&gt;`;
          }).join('');
          rooms += roomCount;
          document.querySelector('#hotel').innerHTML += `&lt;div class=&quot;gate&quot;&gt;
              &lt;h2&gt;${gateName}&lt;/h2&gt;
              &lt;div class=&quot;rooms&quot;&gt;${tpl}&lt;/div&gt;
              &lt;/div&gt;`;
          syncLocalStorage('ADD', tpl.value)
      }
          
      function reserved(el, num) {
          el.classList.toggle('reserved')
      }
  
      document.addEventListener('DOMContentLoaded', function(e) {
          e.preventDefault();
          spawnGate('Gate A', 24);
          spawnGate('Gate B', 24);
          spawnGate('Gate C', 24);
      }, false);
  &lt;/script&gt;
  </code></pre>