DeVuDeveloper / To-Do-list

Add todo, delete todo and remove all completed
https://vudej.github.io/To-Do-list/
MIT License
6 stars 0 forks source link

DRY, KISS, and YAGNI rules. #9

Open DeVuDeveloper opened 2 years ago

DeVuDeveloper commented 2 years ago

I found that it could be nice if I use just 3 properties for the list instead of how it is now. I should refactor code to use only Id instead of both id and index. addBtn.onclick = () => { const id = id${Math.random().toString(16).slice(2)}; const description = document.querySelector('#input').value; const completed = false; const index = listToDo.list.length + 1;

const newTask = { id, description, completed, index, }; if (description) { document.querySelector('#input').value = ''; listToDo.addToDo(newTask); renderList(listToDo); } };