From 075245ca5228445acf8e94e191da36db13dfea50 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 19 Jul 2018 22:25:35 +0200 Subject: [PATCH] Update TodoList.vue 126-128 = Support for the Firefox browser without polyfill (Firefox do not support event as global). Proposition : ```javascript //line 72-80 if (this.filter == 'all') { return this.todos } else if (this.filter == 'active') { return this.todos.filter(todo => !todo.completed) } else if (this.filter == 'completed') { return this.todos.filter(todo => todo.completed) } return this.todos ``` You are returning the same thing with first if and last return the if do not make sense. This should look like that : ```javascript if (this.filter == 'active') { return this.todos.filter(todo => !todo.completed) } else if (this.filter == 'completed') { return this.todos.filter(todo => todo.completed) } return this.todos ``` But personally, I'd use switch over if's, just like this : ```javascript switch (this.filter){ case 'active': return this.todos.filter( todo => !todo.completed ) case 'completed': return this.todos.filter( todo => todo.completed ) } return this.todos //still not sure if this should have default return when all we know all cases ``` Cheers, Jakub --- src/components/TodoList.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/TodoList.vue b/src/components/TodoList.vue index f5a955c..3addc64 100644 --- a/src/components/TodoList.vue +++ b/src/components/TodoList.vue @@ -123,8 +123,8 @@ export default { removeTodo(index) { this.todos.splice(index, 1) }, - checkAllTodos() { - this.todos.forEach((todo) => todo.completed = event.target.checked) + checkAllTodos(event) { + this.todos.forEach((todo) => {todo.completed = event.target.checked}) }, clearCompleted() { this.todos = this.todos.filter(todo => !todo.completed)