From 2cf187ae8af4ce7d56ff2bbcf4f536eedd0c9863 Mon Sep 17 00:00:00 2001 From: Khaliun Baatarkhuu Date: Sun, 26 Jul 2026 21:56:17 +0100 Subject: [PATCH 1/4] changed the title element in the html file --- Sprint-3/alarmclock/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..ff2d3b453 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -4,7 +4,7 @@ - Title here + Alarm clock app
From ddbb891954a1088a021ff8d9aff81793529fe8de Mon Sep 17 00:00:00 2001 From: Khaliun Baatarkhuu Date: Sun, 26 Jul 2026 22:24:24 +0100 Subject: [PATCH 2/4] Revert "changed the title element in the html file" This reverts commit 2cf187ae8af4ce7d56ff2bbcf4f536eedd0c9863. --- Sprint-3/alarmclock/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index ff2d3b453..48e2e80d9 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -4,7 +4,7 @@ - Alarm clock app + Title here
From 7bcada81b8243799e9dd68f42ffaa96b71442929 Mon Sep 17 00:00:00 2001 From: Khaliun Date: Wed, 5 Aug 2026 23:21:34 +0100 Subject: [PATCH 3/4] Add delete completed todos feature --- Sprint-3/todo-list/index.html | 4 ++++ Sprint-3/todo-list/script.mjs | 7 +++++++ Sprint-3/todo-list/todos.mjs | 9 +++++++++ Sprint-3/todo-list/todos.test.mjs | 23 +++++++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..3d11115ae 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -16,6 +16,10 @@

My ToDo List

+ +
    diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index ba0b2ceae..44c00f49f 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -8,6 +8,13 @@ const todos = []; window.addEventListener("load", () => { document.getElementById("add-task-btn").addEventListener("click", addNewTodo); + document + .getElementById("delete-completed-btn") + .addEventListener("click", () => { + Todos.deleteCompleted(todos); + render(); + }); + // Populate sample data Todos.addTask(todos, "Wash the dishes", false); Todos.addTask(todos, "Do the shopping", true); diff --git a/Sprint-3/todo-list/todos.mjs b/Sprint-3/todo-list/todos.mjs index f17ab6a25..acc03678d 100644 --- a/Sprint-3/todo-list/todos.mjs +++ b/Sprint-3/todo-list/todos.mjs @@ -26,4 +26,13 @@ export function toggleCompletedOnTask(todos, taskIndex) { if (todos[taskIndex]) { todos[taskIndex].completed = !todos[taskIndex].completed; } +} + +// Delete all completed tasks +export function deleteCompleted(todos) { + for (let i = todos.length - 1; i >= 0; i--) { + if (todos[i].completed) { + todos.splice(i, 1); + } + } } \ No newline at end of file diff --git a/Sprint-3/todo-list/todos.test.mjs b/Sprint-3/todo-list/todos.test.mjs index bae7ae491..fe6e9bc64 100644 --- a/Sprint-3/todo-list/todos.test.mjs +++ b/Sprint-3/todo-list/todos.test.mjs @@ -130,3 +130,26 @@ describe("toggleCompletedOnTask()", () => { }); }); +describe("deleteCompleted()", () => { + + test("Should delete every completed task", () => { + + const todos = createMockTodos(); + + Todos.deleteCompleted(todos); + + expect(todos).toHaveLength(2); + + expect(todos[0]).toEqual({ + task: "Task 2 description", + completed: false + }); + + expect(todos[1]).toEqual({ + task: "Task 4 description", + completed: false + }); + + }); + +}); From af8ead96e9a0cd6210983abfbc52169389f8e152 Mon Sep 17 00:00:00 2001 From: Khaliun Baatarkhuu Date: Mon, 10 Aug 2026 15:29:11 +0100 Subject: [PATCH 4/4] Refactor delete completed button event handler --- Sprint-3/todo-list/script.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index 44c00f49f..b97f10968 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -10,11 +10,8 @@ window.addEventListener("load", () => { document .getElementById("delete-completed-btn") - .addEventListener("click", () => { - Todos.deleteCompleted(todos); - render(); - }); - + .addEventListener("click", deleteCompletedTodos); + // Populate sample data Todos.addTask(todos, "Wash the dishes", false); Todos.addTask(todos, "Do the shopping", true); @@ -22,6 +19,10 @@ window.addEventListener("load", () => { render(); }); +function deleteCompletedTodos() { + Todos.deleteCompleted(todos) + render(); +} // A callback that reads the task description from an input field and // append a new task to the todo list. @@ -80,4 +81,4 @@ function createListItem(todo, index) { }); return li; -} \ No newline at end of file +}