diff --git a/examples/angularjs/js/services/todoStorage.js b/examples/angularjs/js/services/todoStorage.js index b24b5801e6c4abfb974c9a8596cb2244b223b7bb..a0e4741145a5f4a2ce402db2006d875d3630d9f6 100644 --- a/examples/angularjs/js/services/todoStorage.js +++ b/examples/angularjs/js/services/todoStorage.js @@ -36,14 +36,8 @@ angular.module('todomvc') clearCompleted: function () { var originalTodos = store.todos.slice(0); - var completeTodos = []; - var incompleteTodos = []; - store.todos.forEach(function (todo) { - if (todo.completed) { - completeTodos.push(todo); - } else { - incompleteTodos.push(todo); - } + var incompleteTodos = store.todos.filter(function (todo) { + return !todo.completed; }); angular.copy(incompleteTodos, store.todos); @@ -112,14 +106,8 @@ angular.module('todomvc') clearCompleted: function () { var deferred = $q.defer(); - var completeTodos = []; - var incompleteTodos = []; - store.todos.forEach(function (todo) { - if (todo.completed) { - completeTodos.push(todo); - } else { - incompleteTodos.push(todo); - } + var incompleteTodos = store.todos.filter(function (todo) { + return !todo.completed; }); angular.copy(incompleteTodos, store.todos);