kelvinbush/To-Do-List

Peer-to-Peer review

Closed this issue · 0 comments

Hi @kelvinbush,

Great work on this project 💯. You respected the requirements and you have professional documentation.
Here are some improvements that your team has suggested:

  • We noticed that your code for checking the value of the input is not working, users can still submit empty values. Kindly fix this bug by checking if the input value is empty or not.

    if (value) {
    list.addToDo(value);
    input.value = '';

  • We noticed that you call saveToDos and renderToDos twice, for example in removeToDo you call the methods inside the function, and then you call them again inside rearrangeToDos. To make your code DRY and faster, please consider calling these 2 methods only inside rearrangeToDos.

#rearrangeToDos() {
this.toDos.forEach((toDo, index) => {
toDo.index = index + 1;
});
this.#saveToDos();
this.renderToDos();
}

  • We also noticed that when you restore data from localStorage, you have a function that loops through the array to create objects and pushes them into another array. The array that you get from localStorage is already formatted in that way so you don't need to do it again inside that function. Kindly refactor your code to make it simpler and DRY.

    #addToDoFromStorage(todos) {
    todos.forEach((todo) => {
    const toDo = new ToDo(todo.index, todo.description, todo.completed);
    this.toDos.push(toDo);
    });
    }

  • In the tests, we saw that you're creating new to-dos in each test separately. To make your code DRY and faster, please consider creating the to-dos at the top of the file (outside the tests) so all tests can use the created to-dos and so you don't have to create many todos for each test.

    test('editTask', () => {
    toDoList.addToDo('task1');
    toDoList.addToDo('task2');
    toDoList.addToDo('task3');
    toDoList.updateDescription(1, 'task1 edited');
    document.querySelector('#to-do-list').innerHTML = toDoList.renderToDos();
    expect(document.querySelectorAll('#to-do-list .container')[0].children[1].value)
    .toBe('task1 edited');
    });

Good luck 👍🏻