Skip to content

Commit af8ead9

Browse files
authored
Refactor delete completed button event handler
1 parent 7bcada8 commit af8ead9

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ window.addEventListener("load", () => {
1010

1111
document
1212
.getElementById("delete-completed-btn")
13-
.addEventListener("click", () => {
14-
Todos.deleteCompleted(todos);
15-
render();
16-
});
17-
13+
.addEventListener("click", deleteCompletedTodos);
14+
1815
// Populate sample data
1916
Todos.addTask(todos, "Wash the dishes", false);
2017
Todos.addTask(todos, "Do the shopping", true);
2118

2219
render();
2320
});
2421

22+
function deleteCompletedTodos() {
23+
Todos.deleteCompleted(todos)
24+
render();
25+
}
2526

2627
// A callback that reads the task description from an input field and
2728
// append a new task to the todo list.
@@ -80,4 +81,4 @@ function createListItem(todo, index) {
8081
});
8182

8283
return li;
83-
}
84+
}

0 commit comments

Comments
 (0)