From 09058657af52027d3cfef1c26ffeeba35eb5547a Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Thu, 19 Nov 2026 22:28:30 +0000
Subject: [PATCH 1/8] Change the title in the html file
---
Sprint-3/todo-list/index.html | 78 +++++++++++++++++++++--------------
1 file changed, 47 insertions(+), 31 deletions(-)
diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html
index 4d12c46543..ff54548bdf 100644
--- a/Sprint-3/todo-list/index.html
+++ b/Sprint-3/todo-list/index.html
@@ -1,40 +1,56 @@
-
+
-
-
-
- ToDo List
-
-
+
+
+
+ ToDo List
+
+
-
-
-
-
-
My ToDo List
+
+
+
+
+
My ToDo List
-
-
-
-
+
+
+
+
+
-
-
+
-
-
-
- Task description
-
-
-
-
-
-
-
-
-
+
+
+
+ Task description
+
+
+
+
+
+
+
+
+
From 126bfb0b1b0e859204eac3af96f771a59b865949 Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Fri, 20 Nov 2026 01:11:16 +0000
Subject: [PATCH 2/8] Fix button name in html file
---
Sprint-3/todo-list/index.html | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html
index ff54548bdf..9465aeb668 100644
--- a/Sprint-3/todo-list/index.html
+++ b/Sprint-3/todo-list/index.html
@@ -23,9 +23,7 @@
My ToDo List
placeholder="Enter a new task..."
/>
-
+
@@ -45,9 +43,6 @@
My ToDo List
-
From 1f3ed49c22caf59be0a524ed29d4c7c1722d88f4 Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Fri, 20 Nov 2026 01:13:35 +0000
Subject: [PATCH 3/8] Implement a function deleteCompleted
---
Sprint-3/todo-list/script.mjs | 29 +++++++++++++++++------------
Sprint-3/todo-list/todos.mjs | 10 +++++++++-
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs
index ba0b2ceaec..9abf6dac02 100644
--- a/Sprint-3/todo-list/script.mjs
+++ b/Sprint-3/todo-list/script.mjs
@@ -1,4 +1,4 @@
-// Store everything imported from './todos.mjs' module as properties of an object named Todos
+// Store everything imported from './todos.mjs' module as properties of an object named Todos
import * as Todos from "./todos.mjs";
// To store the todo tasks
@@ -7,16 +7,17 @@ const todos = [];
// Set up tasks to be performed once on page load
window.addEventListener("load", () => {
document.getElementById("add-task-btn").addEventListener("click", addNewTodo);
-
+ document
+ .getElementById("delete-completed-tasks-btn")
+ .addEventListener("click", deleteCompleted);
// Populate sample data
- Todos.addTask(todos, "Wash the dishes", false);
+ Todos.addTask(todos, "Wash the dishes", false);
Todos.addTask(todos, "Do the shopping", true);
-
+ ////////Todos.deleteCompleted(todos);
render();
});
-
-// A callback that reads the task description from an input field and
+// A callback that reads the task description from an input field and
// append a new task to the todo list.
function addNewTodo() {
const taskInput = document.getElementById("new-task-input");
@@ -29,6 +30,11 @@ function addNewTodo() {
taskInput.value = "";
}
+function deleteCompleted() {
+ Todos.deleteCompleted(todos);
+ render();
+}
+
// Note:
// - Store the reference to the
element with id "todo-list" here
// to avoid querying the DOM repeatedly inside render().
@@ -45,12 +51,11 @@ function render() {
});
}
-
// Note:
// - First child of #todo-item-template is a
element.
// We will create each ToDo list item as a clone of this node.
// - This variable is declared here to be close to the only function that uses it.
-const todoListItemTemplate =
+const todoListItemTemplate =
document.getElementById("todo-item-template").content.firstElementChild;
// Create a
element for the given todo task
@@ -62,15 +67,15 @@ function createListItem(todo, index) {
li.classList.add("completed");
}
- li.querySelector('.complete-btn').addEventListener("click", () => {
+ li.querySelector(".complete-btn").addEventListener("click", () => {
Todos.toggleCompletedOnTask(todos, index);
render();
});
-
- li.querySelector('.delete-btn').addEventListener("click", () => {
+
+ li.querySelector(".delete-btn").addEventListener("click", () => {
Todos.deleteTask(todos, index);
render();
});
return li;
-}
\ No newline at end of file
+}
diff --git a/Sprint-3/todo-list/todos.mjs b/Sprint-3/todo-list/todos.mjs
index f17ab6a250..95a57bf778 100644
--- a/Sprint-3/todo-list/todos.mjs
+++ b/Sprint-3/todo-list/todos.mjs
@@ -21,9 +21,17 @@ export function deleteTask(todos, taskIndex) {
}
}
+export function deleteCompleted(todos) {
+ for (let i = todos.length - 1; i >= 0; i--) {
+ if (todos[i].completed) {
+ todos.splice(i, 1);
+ }
+ }
+}
+
// Toggle the "completed" property of todos[taskIndex] if the task exists.
export function toggleCompletedOnTask(todos, taskIndex) {
if (todos[taskIndex]) {
todos[taskIndex].completed = !todos[taskIndex].completed;
}
-}
\ No newline at end of file
+}
From bcf42630d55b2a63d9eb6284d9fa876fdd4c7e7b Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Fri, 20 Nov 2026 01:45:56 +0000
Subject: [PATCH 4/8] write a test that verifies deleteCompleted works
correctly
---
Sprint-3/todo-list/todos.test.mjs | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/Sprint-3/todo-list/todos.test.mjs b/Sprint-3/todo-list/todos.test.mjs
index bae7ae4917..a67a78cd67 100644
--- a/Sprint-3/todo-list/todos.test.mjs
+++ b/Sprint-3/todo-list/todos.test.mjs
@@ -13,7 +13,7 @@ function createMockTodos() {
{ task: "Task 1 description", completed: true },
{ task: "Task 2 description", completed: false },
{ task: "Task 3 description", completed: true },
- { task: "Task 4 description", completed: false },
+ { task: "Task 4 description", completed: false },
];
}
@@ -29,7 +29,6 @@ describe("addTask()", () => {
});
test("Should append a new task to the end of a ToDo list", () => {
-
const todos = createMockTodos();
const lengthBeforeAddition = todos.length;
Todos.addTask(todos, theTask.task, theTask.completed);
@@ -42,7 +41,6 @@ describe("addTask()", () => {
});
describe("deleteTask()", () => {
-
test("Delete the first task", () => {
const todos = createMockTodos();
const todosBeforeDeletion = createMockTodos();
@@ -53,7 +51,7 @@ describe("deleteTask()", () => {
expect(todos[0]).toEqual(todosBeforeDeletion[1]);
expect(todos[1]).toEqual(todosBeforeDeletion[2]);
- expect(todos[2]).toEqual(todosBeforeDeletion[3]);
+ expect(todos[2]).toEqual(todosBeforeDeletion[3]);
});
test("Delete the second task (a middle task)", () => {
@@ -66,7 +64,7 @@ describe("deleteTask()", () => {
expect(todos[0]).toEqual(todosBeforeDeletion[0]);
expect(todos[1]).toEqual(todosBeforeDeletion[2]);
- expect(todos[2]).toEqual(todosBeforeDeletion[3]);
+ expect(todos[2]).toEqual(todosBeforeDeletion[3]);
});
test("Delete the last task", () => {
@@ -79,7 +77,7 @@ describe("deleteTask()", () => {
expect(todos[0]).toEqual(todosBeforeDeletion[0]);
expect(todos[1]).toEqual(todosBeforeDeletion[1]);
- expect(todos[2]).toEqual(todosBeforeDeletion[2]);
+ expect(todos[2]).toEqual(todosBeforeDeletion[2]);
});
test("Delete a non-existing task", () => {
@@ -91,10 +89,15 @@ describe("deleteTask()", () => {
Todos.deleteTask(todos, -1);
expect(todos).toEqual(todosBeforeDeletion);
});
+
+ test("Delete all completed ToDos from the given list", () => {
+ const todos = createMockTodos();
+ Todos.deleteCompleted(todos);
+ expect(todos.every((todo) => !todo.completed)).toBe(true);
+ });
});
describe("toggleCompletedOnTask()", () => {
-
test("Expect the 'completed' property to toggle on an existing task", () => {
const todos = createMockTodos();
const taskIndex = 1;
@@ -111,13 +114,12 @@ describe("toggleCompletedOnTask()", () => {
const todos = createMockTodos();
const todosBeforeToggle = createMockTodos();
Todos.toggleCompletedOnTask(todos, 1);
-
- expect(todos[0]).toEqual(todosBeforeToggle[0]);
+
+ expect(todos[0]).toEqual(todosBeforeToggle[0]);
expect(todos[2]).toEqual(todosBeforeToggle[2]);
expect(todos[3]).toEqual(todosBeforeToggle[3]);
});
-
test("Expect no change when toggling on a non-existing task", () => {
const todos = createMockTodos();
const todosBeforeToggle = createMockTodos();
@@ -129,4 +131,3 @@ describe("toggleCompletedOnTask()", () => {
expect(todos).toEqual(todosBeforeToggle);
});
});
-
From 7d9435d750c2b623f467fe8e7218ab3b7ade3787 Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Fri, 20 Nov 2026 10:05:45 +0000
Subject: [PATCH 5/8] Fix the unexpected html file modifications and add the
Delete completed Tasks button again
---
Sprint-3/todo-list/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html
index 9465aeb668..d7d624f055 100644
--- a/Sprint-3/todo-list/index.html
+++ b/Sprint-3/todo-list/index.html
@@ -23,7 +23,7 @@
My ToDo List
placeholder="Enter a new task..."
/>
-
+
From 8537303f663dfd287d6c5f70774785e884ab8f88 Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Fri, 20 Nov 2026 10:20:16 +0000
Subject: [PATCH 6/8] The test now checks that the incomplete tasks survived
---
Sprint-3/todo-list/todos.test.mjs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Sprint-3/todo-list/todos.test.mjs b/Sprint-3/todo-list/todos.test.mjs
index a67a78cd67..8e032b0dbb 100644
--- a/Sprint-3/todo-list/todos.test.mjs
+++ b/Sprint-3/todo-list/todos.test.mjs
@@ -92,8 +92,12 @@ describe("deleteTask()", () => {
test("Delete all completed ToDos from the given list", () => {
const todos = createMockTodos();
+ const expectedIds = todos
+ .filter((todo) => !todo.completed)
+ .map((todo) => todo.id);
Todos.deleteCompleted(todos);
expect(todos.every((todo) => !todo.completed)).toBe(true);
+ expect(todos.map((todo) => todo.id)).toEqual(expectedIds);
});
});
From 1aadad57e2fb9d98fc134de458bf8360ecc0f9b9 Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Fri, 20 Nov 2026 11:42:35 +0000
Subject: [PATCH 7/8] Add Delete Completed Tasks button
---
Sprint-3/todo-list/index.html | 74 +++++++++++++++--------------------
1 file changed, 32 insertions(+), 42 deletions(-)
diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html
index d7d624f055..4dc1ccdb46 100644
--- a/Sprint-3/todo-list/index.html
+++ b/Sprint-3/todo-list/index.html
@@ -1,51 +1,41 @@
-
+
-
-
-
- ToDo List
-
-
+
+
+
+ ToDo List
+
+
-
-
-
-
-
My ToDo List
+
+
+
+
+
My ToDo List
-
-
-
-
-
+
+
+
+
+
-
+
+
-
-
-
-
- Task description
-
-
-
-
-
-
-
-
+
+
+ Task description
+
+
+
+
+
+
+
+
+
From 41c43f3c97f88b57fea8a4793169618296ffd75a Mon Sep 17 00:00:00 2001
From: Diana <40689028+ausiejute@users.noreply.github.com>
Date: Fri, 20 Nov 2026 11:53:09 +0000
Subject: [PATCH 8/8] Update the title element
---
Sprint-3/alarmclock/index.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html
index 48e2e80d99..18a51fc66b 100644
--- a/Sprint-3/alarmclock/index.html
+++ b/Sprint-3/alarmclock/index.html
@@ -1,10 +1,10 @@
-
+
- Title here
+ Alarm Clock App