-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.js
More file actions
32 lines (29 loc) · 790 Bytes
/
todo.js
File metadata and controls
32 lines (29 loc) · 790 Bytes
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
let todo = [];
let req = prompt("Enter your request");
while(true) {
if(req == "quit") {
console.log("quitting app");
break;
}
if(req == "list") {
console.log("***********************");
for(let i=0; i<todo.length; i++) {
console.log(i, todo[i]);
}
console.log("***********************");
}
else if(req == "add") {
let task = prompt("please enter a task to add");
todo.push(task);
console.log("task added successfully");
}
else if(req == "delete") {
let idx = prompt("please enter the task index");
todo.splice(idx, 1);
console.log("task deleted")
}
else {
console.log("wrong request");
}
req = prompt("Enter your request");
}