-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
74 lines (74 loc) · 2.2 KB
/
index.js
File metadata and controls
74 lines (74 loc) · 2.2 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
import inquirer from "inquirer";
console.log("Hi Welcome to todo list maker");
let todolist = [];
let repeat = true;
let serial = 1;
let update = true;
let del = true;
while (repeat) { // means repeat = true
const asksFortodos = await inquirer.prompt([{
name: "Ask",
type: "input",
message: `What do you want to add in serial no : ${serial} of your todo list?`
},
{
name: "confirmForNext",
type: "confirm",
message: "Do yo want to add more things in your todo list?",
default: "true"
}
]);
if (asksFortodos.Ask !== "") {
todolist.push(serial + "." + asksFortodos.Ask);
serial++;
console.log(todolist);
}
repeat = asksFortodos.confirmForNext;
}
while (update) {
let askforUpdate = await inquirer.prompt({
name: "firstAsk",
type: "confirm",
message: " Are you want to change any list item ?",
default: "false"
});
if (askforUpdate.firstAsk == true) {
let askforUpdate2 = await inquirer.prompt([
{
name: "secondAsk",
type: "number",
message: "Write the number of your element."
},
{
name: "thirdAsk",
type: "string",
message: "Write the value you want to replace it with."
}
]);
if (askforUpdate2.thirdAsk !== "") {
todolist[askforUpdate2.secondAsk - 1] = askforUpdate2.secondAsk + "." + askforUpdate2.thirdAsk;
}
}
update = askforUpdate.firstAsk;
}
while (del) {
let askForDelete = await inquirer.prompt({
name: "ask",
type: "confirm",
message: "Are you want to delete any list item?",
default: "false"
});
if (askForDelete.ask === true) {
let askForDelete2 = await inquirer.prompt({
name: "ask",
type: "number",
message: "Write its serial no : "
});
todolist.splice(askForDelete2.ask - 1, 1);
}
del = askForDelete.ask;
}
console.log("Thanks for using");
console.log(`Here is your todo list items : `);
console.log(todolist);