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:
|
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;
})
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
sortbyfunction 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
Could be changed to: