Adding more functionality to my To-Do List app

[In this post](https://chat-to.dev/post?id=129), I've programmed a simple to-do list app so that we can practice Html, Css and Javascript. And then I decided to continue it by adding more features. Follow the code below. This is how the app looks without the features we're adding below ![the result](https://i.imgur.com/UtSbqMT.jpeg) ## 1. Removing completed tasks Add a button or function to remove all completed tasks at once. ```js const clearCompletedButton = document.getElementById('clear-completed'); clearCompletedButton.addEventListener('click', function() { todos = todos.filter(todo => !todo.completed); renderTodos(); }); ``` ## 2. Counting pending tasks Display the number of pending tasks somewhere on the interface. ```js function countPendingTodos() { const pendingTodos = todos.filter(todo => !todo.completed); return pendingTodos.length; } // Inside the renderAll() function const pendingCount = document.getElementById('pending-count'); pendingCount.textContent = countPendingTodos(); ``` ## 3. Editing tasks Allow users to edit the text of tasks directly in the list. ```js function editTodo(index, newText) { todos[index].text = newText; renderTodos(); } // Add this code inside the renderAll() function, after creating the <li> element li.setAttribute('contenteditable', true); li.addEventListener('blur', function() { editTodo(index, li.textContent); }); ``` ## 4. Data persistence Save the task list data locally so that it persists between sessions. ```js function saveTodos() { localStorage.setItem('todos', JSON.stringify(todos)); } function loadTodos() { const storedTodos = localStorage.getItem('todos'); if (storedTodos) { todos = JSON.parse(storedTodos); renderTodos(); } } // Call the loadAll() function after defining the all variable loadTodos(); ``` These are just a few ideas for expanding the functionality of the to-do list application. You can adapt and expand these suggestions as necessary to suit your needs. I'd love to read in the comments about more functionality we can add to the app. Feel free to write the code for your feature here

To comment this publication you need to be logged in.