-
-
Save evansedlar/07e5c1cb73ff96c24295bdae3bcf3587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let todo = [] | |
while(true) { | |
let choice = prompt('enter 1 to add item, 2 to delete item, enter 3 to view all items, q to quit') | |
if(choice == 'q') { | |
break | |
} | |
if(choice == '1') { | |
let taskName = prompt('Enter task name: ') | |
let taskPriority = prompt('Enter task priority: ') | |
let task = { id: todo.length + 1, name: taskName, priority: taskPriority } | |
todo.push(task) | |
} | |
else if(choice == '2') { | |
let taskDelete = prompt('Enter the number associated with your task in the todo list.'); | |
for (let index = 0; index < todo.length; index++) { | |
if (taskDelete == todo[index].id) { | |
todo.splice(index, 1) | |
} | |
} | |
} | |
else if(choice == '3') { | |
console.log(todo) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment