-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodos.js
28 lines (26 loc) · 950 Bytes
/
todos.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
let input = prompt("what would you like to do?");
const todos = ['Collect Chicken Eggs', 'Clean Litter Box'];
while(input !== 'quit' && input !== 'q'){
if(input === 'list'){
console.log('***************')
for(let i=0; i<todos.length; i++){
console.log(`${i}: ${todos[i]}`);
}
console.log('***************')
}else if(input === 'new'){
const newTodo = prompt('Ok, what is the new todo');
todos.push(newTodo);
console.log(`${newTodo} added to the list!`)
}else if(input === 'delete'){
const indexStr = parseInt(prompt('Ok, enter an index to delete:'));
if(!Number.isNaN(index )){
const deleted = todos.splice(index, 1);
console.log(`Ok, deleted ${deleted[0]}`);
}
else{
console.log('Unknown index');
}
}
input = prompt("what would you like to do?")
}
console.log("OK QUIT THE APP!")