-
-
Save BLO2210/2a13b7c3654783732a1cbd820a331639 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 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