diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..6f7642a6e 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -34,7 +34,9 @@

My ToDo List

- +
+ +
diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index ba0b2ceae..74d3e0274 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -1,3 +1,4 @@ + // Store everything imported from './todos.mjs' module as properties of an object named Todos import * as Todos from "./todos.mjs"; @@ -45,7 +46,16 @@ function render() { }); } - + // Delete completed tasks button + document.getElementById("delete-completed-btn").addEventListener("click", () => { + // Keep only tasks that are NOT completed + for (let i = todos.length - 1; i >= 0; i--) { + if (todos[i].completed) { + Todos.deleteTask(todos, i); // call your module function + } + } + render(); + }); // Note: // - First child of #todo-item-template is a
  • element. // We will create each ToDo list item as a clone of this node. @@ -73,4 +83,4 @@ function createListItem(todo, index) { }); return li; -} \ No newline at end of file +}