| 10 | renderTodoList(); |
| 11 | |
| 12 | function renderTodoList() { |
| 13 | let todoListHTML = ''; |
| 14 | |
| 15 | for (let i = 0; i < todoList.length; i++) { |
| 16 | const todoObject = todoList[i]; |
| 17 | //const name = todoObject.name; |
| 18 | //const dueDate = todoObject.dueDate; |
| 19 | const { name, dueDate } = todoObject; |
| 20 | const html = ` |
| 21 | <div>${name}</div> |
| 22 | <div>${dueDate}</div> |
| 23 | <button onclick=" |
| 24 | todoList.splice(${i}, 1); |
| 25 | renderTodoList(); |
| 26 | |
| 27 | // Whenever we update the todo list, save in localStorage. |
| 28 | saveToStorage(); |
| 29 | " class="delete-todo-button">Delete</button> |
| 30 | `; |
| 31 | todoListHTML += html; |
| 32 | } |
| 33 | |
| 34 | document.querySelector('.js-todo-list') |
| 35 | .innerHTML = todoListHTML; |
| 36 | } |
| 37 | |
| 38 | function addTodo() { |
| 39 | const inputElement = document.querySelector('.js-name-input'); |