My todo list deletes the wrong item every single time, help
const list = document.getElementById('todoList');
function addItem(text) {
const li = document.createElement('li');
li.textContent = text;
const removeBtn = document.createElement('button');
removeBtn.textContent = 'Remove';
removeBtn.addEventListener('click', () => {
list.removeChild(li.parentElement);
});
li.appendChild(removeBtn);
list.appendChild(li);
}
addItem('Buy milk');
addItem('Walk dog');
addItem('Write code');
Reply with what is broken and how you would fix it.