Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sprint-3/todo-list/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ <h1>My ToDo List</h1>
</div>
</li>
</template>

<div>
<button id="delete-completed-btn">Delete Completed</button>
</div>
</div>
</body>
</html>
14 changes: 12 additions & 2 deletions Sprint-3/todo-list/script.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// Store everything imported from './todos.mjs' module as properties of an object named Todos
import * as Todos from "./todos.mjs";

Expand Down Expand Up @@ -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 <li> element.
// We will create each ToDo list item as a clone of this node.
Expand Down Expand Up @@ -73,4 +83,4 @@ function createListItem(todo, index) {
});

return li;
}
}