Skip to content

Instantly share code, notes, and snippets.

@BLO2210
Created February 15, 2023 21:19
Show Gist options
  • Save BLO2210/2a13b7c3654783732a1cbd820a331639 to your computer and use it in GitHub Desktop.
Save BLO2210/2a13b7c3654783732a1cbd820a331639 to your computer and use it in GitHub Desktop.
let tasks = []
function viewList() {
for (let i = 0; i <tasks.length; i++)
console.log(`${tasks[i].name} ${tasks[i].priority}`)
}
while(true) {
let choice = prompt('Enter 1 to add item, enter 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 = {name: taskName, priority: taskPriority}
tasks.push(task)
}
if(choice == '2') {
let deleteTask = prompt('Enter the index number of the task you wish to delete');
for (let i = 0; i < tasks.length; i++);
tasks.splice(deleteTask, 1); }
if(choice == '3') {
viewList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment