todo-alesscuderi
v1.0.0
Published
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.
Downloads
1
Readme
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)
return
You 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";
return
Task ${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";
return
Task ${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
})
return
User ${newUser.name} has been added!
};
seeTodos
shows the todos list
var seeTodos = function () {
return todos;
};