In this article we are going to work on JS version that uses “addEventListener” method instead of the “onclick” in HTML, which is perhaps considered more primitive and suitable for complete beginners. The code bellow already has the possibility to adds tasks to the list, and a complete and delete button. What we’ll now add is:
- A saveTasks() function to store the tasks in local storage.
- A loadTasks() function to load saved tasks when the page loads.
This means we will update the existing code to save changes whenever a task is added, completed, or deleted, even after the browser window is closed or refreshed.