Skip to content

Awesome logic.js - could be refactored a tiny bit #69

Description

@helenzhou6

We loved the fact that you put the two different sort functions in your logic.js file (rather than in the dom.js file - which makes more sense). And then in the logic.js sortby function section you just passed in the two other functions depending on what you want. So you can do unit tests on each one easily! LOVE IT 😍

Just very minor point - you could refactor your functions:

jikt-todo/logic.js

Lines 56 to 62 in 194b927

let toggledArray = localTodos.map(function(item){
if(item.id===idToMark){
item.done=!item.done;
}
return item;
})
return toggledArray;

Could be changed to:

     let localTodos = this.cloneArrayOfObjects(todos);
     return localTodos.map(function(item){
       if(item.id===idToMark){
         item.done=!item.done;
       }
       return item;
     })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions