Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions todo_list.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
var newTodoList = function() {
// ???
function Task(id, description) {
this.id = id;
this.description = description;
this.completed = false;

this.complete = function() {
this.completed = true;
};
}


var TodoList = function() {
this.tasks = [];
var id = this.tasks.length + 1;
this.add = function(description) {
var a = new Task(id, description);
this.tasks.push(a);
id++;
};
this.list = function() {
for(var i=0;i< this.tasks.length;i++) {
console.log(this.tasks[i].description);
}
};
this.remove = function(i) {
delete this.tasks[i];
};
};

// // Driver code

// var groceryList = new TodoList(1, 'cheese')

// console.log(groceryList)



// Driver code
// // Driver code


var todoList = newTodoList();
// var todoList = newTodoList();