removeChild(li. parentElement) removes the list itself, not the li. Should just be list. removeChild(li), since list and li are already in scope from the closure.
Spot the Bug answer: The click handler removes li.parentElement (the list itself) instead of the li item that contains the clicked button
The fix:
list.removeChild(li);
Why:
li.parentElement refers to the ul (list), not the individual todo item, so calling removeChild on it tries to remove the whole list from its parent instead of removing the specific li. The handler should remove li directly since that is the element containing the button that was clicked.