-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.js
45 lines (45 loc) · 1.4 KB
/
todo.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
39
40
41
42
43
44
45
import inquirer from "inquirer";
let to_do_list = [];
while (true) {
let options = await inquirer.prompt([{
type: "list",
name: "userOptions",
message: "What do you want to do?",
choices: ["ADD", "REMOVE", "SEE LIST", "EXIT"]
}]);
if (options.userOptions === "ADD") {
let addOption = await inquirer.prompt([{
type: "input",
name: "addtask",
message: "What do you want to add?"
}]);
to_do_list.push(addOption.addtask);
console.log(to_do_list);
}
;
if (options.userOptions === "REMOVE") {
let removeOption = await inquirer.prompt([{
type: "list",
name: "removetask",
message: "What do you want to remove?",
choices: to_do_list
}]);
const index = to_do_list.indexOf(removeOption.removetask);
to_do_list.splice(index, 1);
console.log("\n current TO_DO LIST");
console.log(to_do_list);
}
if (options.userOptions === "SEE LIST") {
if (to_do_list.length === 0) {
console.log("Your list is Empty");
}
else {
console.log("\n Your TO_DO LIST");
console.log(to_do_list);
}
}
if (options.userOptions === "EXIT") {
console.log("Thanks for using our program");
break;
}
}