todo-alesscuderi

1.0.0 • Public • Published

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; };

Readme

Keywords

none

Package Sidebar

Install

npm i todo-alesscuderi

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

4.99 kB

Total Files

6

Last publish

Collaborators

  • alesscuderi