title: How do I get the splice() method to work in my todo list?
body: <p>I´m building a simple todo list and will use the splice method to remove items from the list. I can't get it to work. I get the spliced item to the console so the &quot;connection&quot; between my remove button and my remove function seems to work. I also tried the slice method and that works, but for some reason the splice method won't work. Below is the array that I use to push in my new items to my class, the function that creates the HTML for the new todo items and the remove items function. Any idea why the splice method won't work?</p>
  <pre><code>//ARRAY FOR NEW TODO ITEMS
  let newTodo: Todo[] = [];
  
  // FUNCTION THAT CREATES THE HTML FOR THE NEW TODO ITEM
  
      let doneBtn = document.createElement(&quot;button&quot;);
  
  function htmltask() {
    let taskDiv = document.createElement(&quot;div&quot;);
  
    taskDiv.innerHTML = &quot;&quot;;
  
    for (let i = 0; i &lt; newTodo.length; i++) {
      taskDiv.className = &quot;taskDiv&quot;;
      taskDiv.innerHTML = newTodo[i].todoItem;
  
      let btnContainer = document.createElement(&quot;div&quot;);
      btnContainer.className = &quot;btnContainer&quot;;
  
      // REMOVEBTN //
      let removeBtn = document.createElement(&quot;button&quot;);
      removeBtn.innerHTML = &quot;REMOVE&quot;;
      removeBtn.addEventListener(&quot;click&quot;, (e) =&gt; {
        remove(e, i);
      });
  
      // DONEBTN //
      let doneBtn = document.createElement(&quot;button&quot;);
      doneBtn.innerHTML = &quot;DONE&quot;;
      doneBtn.className = &quot;doneBtn&quot;;
  
      newTaskDiv.appendChild(taskDiv);
      taskDiv.appendChild(btnContainer);
      btnContainer.appendChild(doneBtn);
      btnContainer.appendChild(removeBtn);
    }
  
    localStorage.setItem(&quot;newTodo&quot;, JSON.stringify(newTodo));
  }
  
  // FUNCTION TO REMOVE ITEMS
  function remove(e: Event, i: number) {
    newTodo.splice(i, 1);
    htmltask();
  }
  </code></pre>