title: How to keep array of objects in localstorage
body: <p>i'm trying to use localstorage for my array of objects but it doesn't work (without the localstorage it works perfectly). after a few days of tries i'm trying here. can anyone help please?
  The Code:</p>
  <pre><code>  &lt;script&gt;
          var notes = JSON.parse(localstorage.getitem(&quot;notes&quot;) || &quot;[]&quot;);        
          function todo() { // Gets invoked by a submit button        
              var list = document.getElementById(&quot;tasklist&quot;).value;        
              var taskdate = document.getElementById(&quot;taskdate&quot;).value;        
              var tasktime = document.getElementById(&quot;tasktime&quot;).value;        
              
              const note = {
                  list: list,
                  taskdate: taskdate,
                  tasktime: tasktime
              }
              notes.push(note);
              for (i = 0; i &lt; notes.length; i++) {
                  document.getElementById(&quot;name&quot;).append(notes[i].list);
              }
              localStorage.setItem(&quot;notes&quot;, JSON.stringify(notes));
          }
      &lt;/script&gt;
  </code></pre>