-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.ts
52 lines (43 loc) · 1.27 KB
/
todo.ts
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
46
47
48
49
50
51
52
import inquirer from "inquirer"
let to_do_list : string[] = [];
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;
}
}