I am creating a basic todo - list and the input field seems to save all the data entered as a drop down list and I am unable to fix it.I have tried using the.reset() fn and also other options shown here like using val("") or val(0) and nothing seems to work.So can anyone suggest how I can fix this. I had tried the return fn and the val function as well but it still wouldn't work.Thanks in advance.
const addForm = document.querySelector('.add');
const todolst = document.querySelector('.todolst');
const deletelst = document.querySelector('.delete')
const task = addForm.add.value.trim();
const newTemplate = task => {
const html =
<li class="list-group-item d-flex justify-content-between align-items-center"><span>${task}</span><i class="far fa-trash-alt delete"></i></li>
todolst.innerHTML += html
}
// to add a tag
addForm.addEventListener('Enter', e => {
e.preventDefault();
if (task.length) {
newTemplate(task);
addForm.val(0);
}
});
[enter image description here][1]
[1]: https://i.stack.imgur.com/gIdeL.png