forked from lighthouse-labs/todo-list-js-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (29 loc) · 951 Bytes
/
index.js
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
38
function newTask(title, description) {
const task = {
title: title,
description: description,
complete: false,
logState: function() {
console.log(`${this.title} has${this.complete ? " " : " not "}been completed`);
},
markCompleted: function() {
this.complete = true;
}
};
return task;
}
// marks the provided task as completed
function completeTask(task) {
task.complete = true;
}
// Print the state of a task to the console in a nice readable way
function logTaskState(task) {
console.log(`${task.title} has ${task.complete ? " " : " not "} been completed`);
}
// DRIVER CODE BELOW
const task1 = newTask("Clean Cat Litter", "Take all the poop out of the litter box");
const task2 = newTask("Do Laundry", "Suprised")
const tasks = [task1, task2];
task1.logState(0); // Clean Cat Litter has not been completed
task1.markCompleted(0);
task1.logState(0); // Clean Cat Litter has been completed