const todos = [{ text: 'Order Cat food', completed: false }, { text: 'Clean kitchen', completed: true }, { text: 'Buy food', completed: true }, { text: 'Do work', completed: false }, { text: 'Exercise', completed: true }] // 1. Convert array to array of objects -> text, completed // 2. Create function to remove a todo by text value const deleteTodo = function (todos, todoText) { const index = todos.findIndex(function(array) { if (array.text.toLowerCase() === todoText.toLowerCase()){ console.log(`found!`) } console.log(`not found!`) return array.text.toLowerCase() === todoText.toLowerCase() }) // console.log(index) if (index > -1) { todos.splice(index, 1) console.log(`deleted index at ${index}`) } } // returns only the items that are set to completed: false const getThingsToDo = function (todos) { return todos.filter(function (todo, index) { return !todo.completed }) } // console.log(getThingsToDo(todos)) // deleteTodo(todos, 'buy food') // console.log(todos) // false 0 < true 1 returns true // true 1 < false 0 returns false // false should be top, true will be on bottom // const sortTodos = function(todos) { todos.sort(function(a, b) { if (!a.completed && b.completed ) { return -1 } else { if (!b.completed && a.completed) { return 1 } else { return 0 } } }) } sortTodos(todos) console.log(todos)