'trying to make a mark off for the to do App

I am currently busy trying to make a mark off to the list when it is done for the to-do app.

here is the JS code for it:


let tasks = [];

function todo(text) {
  const todo = {
    text,
    checked: false,
    id: Date.now(),

  };

  tasks.push(todo);
  displaytasks(todo);
}


const list = document.querySelector('.list')


list.addEventListener('click', event =>{
  if(event.target.classList.contains('js-tick')){
  const itemKey = event.target.parentElement.dataset.key;
  toggleDone(itemkey);
}
});

function  toggleDone(key)
{
  const index = tasks.findIndex(item => item.id === Number(key));

  tasks[index].checked =!tasks[index].checked;
  displaytasks(tasks[index]);
}

I have the tasks displaying, but it does not mark off when I click the circle that makes a tick and a line through.

In the console, I do not see it firing at all. As you can see I passed through the toggleDone(itemkey) to the function toggleDone(key)



Solution 1:[1]

changed

const itemKey = event.target.parentElement.dataset.key; toggleDone(itemkey); to

toggleDone(itemKey);

which fixed it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AspiringDev