From 2b1b28b8caed97c74ea5fbd48e436bb2f59b3e3e Mon Sep 17 00:00:00 2001 From: Asanda Date: Wed, 16 Sep 2026 11:33:46 +0200 Subject: [PATCH 1/2] Add mass delete for completed todos --- Sprint-3/todo-list/index.html | 3 +++ Sprint-3/todo-list/package.json | 6 +++--- Sprint-3/todo-list/script.mjs | 5 +++++ Sprint-3/todo-list/todos.mjs | 9 +++++++++ Sprint-3/todo-list/todos.test.mjs | 18 ++++++++++++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..b31069d8f 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -16,8 +16,11 @@

My ToDo List

+
+ + diff --git a/Sprint-3/todo-list/package.json b/Sprint-3/todo-list/package.json index ce181158a..2262f3d00 100644 --- a/Sprint-3/todo-list/package.json +++ b/Sprint-3/todo-list/package.json @@ -5,8 +5,8 @@ "description": "You must update this package", "type": "module", "scripts": { - "serve": "http-server", - "test": "NODE_OPTIONS=--experimental-vm-modules jest" + "serve": "http-server", + "test": "set NODE_OPTIONS=--experimental-vm-modules && jest" }, "repository": { "type": "git", @@ -17,7 +17,7 @@ }, "homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme", "devDependencies": { - "http-server": "^14.1.1", + "http-server": "^14.1.1", "jest": "^30.0.4" } } diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index ba0b2ceae..cf400e7f4 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -7,6 +7,7 @@ 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-btn").addEventListener("click",deleteCompletedTodos); // Populate sample data Todos.addTask(todos, "Wash the dishes", false); @@ -28,6 +29,10 @@ function addNewTodo() { taskInput.value = ""; } +function deleteCompletedTodos() { + Todos.deleteCompleted(todos); + render(); +} // Note: // - Store the reference to the