-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.js
More file actions
36 lines (36 loc) · 1.15 KB
/
todo.js
File metadata and controls
36 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
exports.__esModule = true;
var Todo = /** @class */ (function () {
function Todo() {
this.tasks = [];
}
Todo.prototype.cosntructior = function () { };
Todo.prototype.addTask = function (task) {
this.tasks.push(task);
console.log("_______________ New Task Added _______________");
console.log("Task " + task + " inserted in the list");
return this.tasks.length;
};
Todo.prototype.listAllItems = function () {
console.log("Start: All items in Array");
this.tasks.forEach(function (task) {
console.log(task);
});
console.log("End: All items in Array");
};
Todo.prototype.deleteTask = function (task) {
var index = this.tasks.indexOf(task);
if (index > -1) {
this.tasks.splice(index, 1);
console.log("______________ Task Removed ______________");
console.log("Task " + task + " removed from list.");
}
return this.tasks.length;
};
return Todo;
}());
var myTodos = new Todo();
myTodos.addTask('eat');
myTodos.addTask('sleep');
myTodos.listAllItems();
myTodos.deleteTask('sleep');