-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.js
More file actions
37 lines (29 loc) · 890 Bytes
/
Copy pathlist.js
File metadata and controls
37 lines (29 loc) · 890 Bytes
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
37
class Todo {
constructor(title, description, nextTodoIndex = -1) {
this.title = title;
this.description = description;
this.nextTodoIndex = nextTodoIndex;
}
printDetails() {
console.log(`Title: ${this.title}`);
console.log(`Description: ${this.description}`);
if (this.nextTodoIndex !== -1) {
console.log(`Points to next TODO at index: ${this.nextTodoIndex}`);
} else {
console.log("No next TODO");
}
console.log("\n---\n");
}
}
const todosArray = [
new Todo("Programming", "Learn JS", 2),
new Todo("Fising", "Catch fish", 3),
new Todo("Drive", "Drive a vehicle", 4),
new Todo("Sleep", "Go to bed", -1),
];
function printAllTodos() {
for (const todo of todosArray) {
todo.printDetails();
}
}
printAllTodos();