Created
May 22, 2022 21:34
-
-
Save marc-lapierre/956fe11ecfa441ceded78dfe68a5156b to your computer and use it in GitHub Desktop.
todo.js
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
console.warn('Program - Started') | |
let input = prompt('what would you like to do?') | |
const todos = ['Walk the dog', 'Order Pizza'] | |
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('Enter new task') | |
todos.push(newTodo) | |
console.log(`${newTodo} - Added`) | |
} else if (input === 'delete') { | |
const index = parseInt(prompt('Enter index to delete')) | |
if (!Number.isNaN(index)) { | |
const deletedTask = todos.splice(index, 1) | |
console.log(`${deletedTask[0]} - Deleted`) | |
} else { | |
console.log('Unknown Index') | |
} | |
} | |
input = prompt('what would you like to do?') | |
} | |
console.warn('Program - Closed') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment