1.0.0 • Published 6 years ago

todo-alesscuderi v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

TodoManager

This package contains the functions that manage a todo app and its users. It allows add and delete todos, set them done and to do and adds the users.

installation

npm install todo --save

Functions

addTodo()

adds a todo

var addTodo = function(newTodo) { var lastId = todos.length; todos.push({ id: lastId+1, creatorId: newTodo.creatorId, assignedId: newTodo.assignedId, task: newTodo.task, isCompleted: "No" }) return 'New todo created!'; };

deleteTask()

deletes a todo var deleteTask = function(id) { for (var index in todos) { if (id===todos[index].id) { var deletedId = todos[index].id; todos.splice(todos[index],1) returnYou have removed task ${deletedId}; } } return null }

setDone

Sets a task done var setDone = function (id) { for (var index in todos) { if (id === todos[index].id) { todos[index].isCompleted = "Yes"; returnTask ${id} has been completed!} } return null; };

setTodo

Sets a task to do var setTodo = function (id) { for (var index in todos) { if (id === todos[index].id) { console.log("going on..."); todos[index].isCompleted = "No"; returnTask ${id} has been is set to do!} } return null; };

addUser

adds an user var addUser = function (newUser) { var lastUserId = users.length; users.push({ id: lastUserId+1, name: newUser.name }) returnUser ${newUser.name} has been added!};

seeTodos

shows the todos list var seeTodos = function () { return todos; };