title: I'm having trouble removing an item from localStorage for my tasklist app which i'm building using vanilla javascript
body: <p>Here's a function i'm having trouble with the foreach loop traverses just fine but i'm having trouble removing item from localStorage.</p>
  <pre><code>function removeFromLocalStorage(taskItem) {
    let tasks;
     if (localStorage.getItem(&quot;tasks&quot;) === null) {
        tasks = [];
     } else {
        tasks = JSON.parse(localStorage.getItem(&quot;tasks&quot;));
     }
  
     tasks.forEach((task, index) =&gt; {
        if (task === taskItem) {
        tasks = localStorage.removeItem(task);
        }
    });
    }
  </code></pre>