Simple question here. I am slowly building a to do list program. Whilst you do not quit I would like to the program to keep looping. But it keeps asking 'What is the to do text' after it is inputted?
Whereas I would like it to loop back to the beginning 'What would you like to do' so I can add additional functions such as: list the to do's Delete a to do
Code below:
while (input.toLowerCase() !== 'quit') {
const list = [];
if (input === 'new') {
let todo = prompt('What is the to do text')
list.push(todo);
}
}
CodePudding user response:
you need to define input first and i would put the list outside the while loop because if you dont the list get overwritten each time.
let input = ''
const list = [];
while (input.toLowerCase() !== 'quit') {
input = prompt('What do you want to do?')
if (input === 'new') {
let todo = prompt('What is the to do text')
list.push(todo);
}
}