diff --git a/todo_list.js b/todo_list.js index 110fce6..23de106 100644 --- a/todo_list.js +++ b/todo_list.js @@ -1,10 +1,40 @@ -var newTodoList = function() { - // ??? +// function ToDoList() { +// this.tasks = [] +// } + +function Task(task) { + this.task = task, + this.completed = false, + this.description = 'buy ' + task }; +Task.prototype.complete = function() { + this.completed = true; +} +function ToDoList() { + this.tasks = []; +}; -// Driver code +ToDoList.prototype.add = function(task) { + var newTask = new Task(task); + this.tasks.push(newTask); + var index = this.tasks.indexOf(newTask); + this.tasks[index].id = index + 1 +}; + +ToDoList.prototype.list = function() { + for (i=0; i < this.tasks.length; i++) { + console.log(this.tasks[i]); + } +}; + + + +fooList = new ToDoList(); +fooList.add('sweet stuff'); +fooList.add('foo foo'); + +// Driver code -var todoList = newTodoList(); \ No newline at end of file