Learn localStorage by Building a Todo App - Step 38

Tell us what’s happening:

I don’t think I fully understand what is happening when I call the parentElement (or childElement) but right now the error code I can’t shake is “You should use the remove() method to remove the parent element of buttonEl.” I had “buttonEl.remove(parentElement);” before, and a few other similar things.

Your code so far

const deleteTask = (buttonEl) => {
  const dataArrIndex = taskData.findIndex(
    (item) => item.id === buttonEl.parentElement.id
  );
    remove(buttonEl.parentElement);
    taskData.splice(dataArrIndex, 1);
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 38

update- making it taskData.remove(buttonEl.parentElement) doesn’t work

you need to call remove on the element you want to remove, so in this case it would be element.remove(), your element is buttonEl.parentElement.

2 Likes

Thank you. I appreciate your help

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.