ClaudiaRojasSoto / toDo_list

This exercise builds a simple to-do list using WebPack and then serving it with Webpack dev server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improved task status handling

ClaudiaRojasSoto opened this issue · comments

I congratulate you on the code I saw in this application. Undoubtedly a very clear and understandable code. I found something that can help you make it even easier:
In the statusUpdates.js file, you are using the saveTasks function imported from taskFunctions.js to save the status of tasks to local storage. However, you might consider calling saveTasks just once after performing all task update operations instead of doing it in each individual addTask, deleteTask, and editTask function. This will prevent unnecessary writes to local storage and improve performance.

export const addTask = (tasks, description) => {
const task = {
description,
completed: false,
index: tasks.length + 1,
};
tasks.push(task);
saveTasks(tasks);
return tasks;
};
export const deleteTask = (tasks, index) => {
tasks.splice(index, 1);
tasks.forEach((task, i) => {
task.index = i + 1;
});
saveTasks(tasks);
return tasks;
};
export const editTask = (tasks, index, newDescription) => {
tasks[index].description = newDescription;
saveTasks(tasks);