Skip to content

Commit ff96587

Browse files
Declare the function to handle deletion of completed task
1 parent 9455547 commit ff96587

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎Sprint-3/todo-list/script.mjs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ function addNewTodo() {
3232
taskInput.value = "";
3333
}
3434

35+
function deleteCompletedTodos() {
36+
const newTodos = Todos.deleteCompleted(todos);
37+
38+
// Replace the old array contents
39+
todos.length = 0;
40+
todos.push(...newTodos);
41+
42+
render();
43+
}
44+
45+
3546
// Note:
3647
// - Store the reference to the <ul> element with id "todo-list" here
3748
// to avoid querying the DOM repeatedly inside render().

0 commit comments

Comments
 (0)