Skip to content

Instantly share code, notes, and snippets.

@imparvez
Created September 18, 2017 13:53
Show Gist options
  • Save imparvez/bbcab8a0cefcb854cf7ef127f39d2c2c to your computer and use it in GitHub Desktop.
Save imparvez/bbcab8a0cefcb854cf7ef127f39d2c2c to your computer and use it in GitHub Desktop.
// V3 Objects
// It should store the todos arrays on an object
// It should have a display todos method
// It should have an addTodo method
// It should have a changeTodo method
// It should have a deleteTodo method
var todoList = {
todos: ['item 1', 'item 2', 'item 3'], // 1. It should store the todos arrays on an object
displayTodos: function(){
console.log('My Todos: ', this.todos)
},
addTodos: function(newTodo){
this.todos.push(newTodo);
this.displayTodos();
},
changeTodo: function(pos, newTodo) {
this.todos[pos] = newTodo;
this.displayTodos();
},
deleteTodo: function(pos) {
this.todos.splice(pos, 1);
this.displayTodos();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment