Skip to content

Commit aedcd82

Browse files
implemented the delete completed function to delete all the tasks that has been completed
1 parent 08149c3 commit aedcd82

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ export function toggleCompletedOnTask(todos, taskIndex) {
2626
if (todos[taskIndex]) {
2727
todos[taskIndex].completed = !todos[taskIndex].completed;
2828
}
29-
}
29+
}
30+
// remove all the completed tasks from the given list
31+
export function deleteCompleted(toDoList) {
32+
for (let i = toDoList.length - 1; i >= 0; i--) {
33+
if (toDoList[i].completed) {
34+
deleteTask(toDoList, i);
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)