Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions Sprint-3/todo-list/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
{
"name": "todo-list",
"version": "1.0.0",
"license": "CC-BY-SA-4.0",
"description": "You must update this package",
"type": "module",
"scripts": {
"serve": "http-server",
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/CodeYourFuture/CYF-Coursework-Template.git"
},
"bugs": {
"url": "https://github.com/CodeYourFuture/CYF-Coursework-Template/issues"
},
"homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme",
"devDependencies": {
"http-server": "^14.1.1",
"jest": "^30.0.4"
}
}
"license": "CC-BY-SA-4.0",
"description": "You must update this package"
}
18 changes: 13 additions & 5 deletions Sprint-3/todo-list/todos.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
the following manner:

[
{ task: "Description of task 1", completed: false},
{ task: "Description of task 2", completed: true}
{ task: "Description of task 1", completed: false },
{ task: "Description of task 2", completed: true }
]

*/

// Append a new task to todos[]
Expand All @@ -21,9 +20,18 @@ export function deleteTask(todos, taskIndex) {
}
}

// Toggle the "completed" property of todos[taskIndex] if the task exists.
// 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;
}
}
}

// Remove all tasks that are marked as completed§
export function deleteCompleted(todos) {
for (let i = todos.length - 1; i >= 0; i--) {
if (todos[i].completed) {
todos.splice(i, 1);
}
}
}
Loading