Skip to content

Commit c2e02c1

Browse files
committed
Implement deleteCompleted function to remove completed tasks from the todo list
1 parent 3b4ae69 commit c2e02c1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,13 @@ export function toggleCompletedOnTask(todos, taskIndex) {
2626
if (todos[taskIndex]) {
2727
todos[taskIndex].completed = !todos[taskIndex].completed;
2828
}
29-
}
29+
}
30+
31+
// Remove every task whose "completed" property is true
32+
export function deleteCompleted(todos) {
33+
for (let i = todos.length - 1; i >= 0; i--) {
34+
if (todos[i].completed) {
35+
todos.splice(i, 1);
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)