-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.js
More file actions
60 lines (57 loc) · 1.41 KB
/
todo.js
File metadata and controls
60 lines (57 loc) · 1.41 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
// let todo = [];
// let req = ("enter the request what you want");
// while(true){
// if(req == "quit"){
// console.log("quitting app");
// break;
// }
// else if(req == "list"){
// console.log("--------------------------");
// for(let i=0;i<todo.length;i++){
// console.log(todo[i]);
// }
// console.log("--------------------------");
// }
// else if(req == "add"){
// let task = ("enter the new task");
// todo.push(task);
// console.log("task added");
// }
// else if(req == "delete"){
// let idx = ("enter the task index that you want to get delete");
// todo.splice(idx,1);
// console.log("task deleted");
// }else{
// console.log("wrong request");
// }
// req = ("enter the request what you want");
// }
let todo=[];
let work = prompt("enter a task");
while(true){
if(work == "quit"){
console.log("quitting app");
break;
}
else if(work == "list"){
console.log("----------------");
for(let i=0;i<todo.length;i++){
console.log(todo[i]);
}
console.log("---------------------");
}
else if(work == "add"){
let add = prompt("enter a task");
todo.push(add);
console.log("task added");
}
else if(work == "delete"){
let dlte = prompt("enter the deleted index")
todo.slice(dlte,1);
console.log("task deleted");
}
else{
console.log("invalid work");
}
work = prompt("enetr the work");
}