I am getting 9+ errors at the end of my code saying "Declaration or Statement Expected." I am pretty sure my syntax is correct but I could be wrong. The program runs fine, just wondering why I am getting these errors. The error displays in VSCODE, I don't see the error here. Here is a picture: VSCODE SCREENSHOT NOTE: IF YOU RUN THE CODE JUST TYPE 'quit' and it will exit.
let toDoList = [];
let input = prompt("What Would You Like to Do");
while (input!== 'quit'){
if (input === "new".toLowerCase())
{
let addAToDo = prompt("What Would You Like to Add?") ;
toDoList.push(addAToDo)
console.log( `${addAToDo} added to the list!`)
}
else if (input === "list".toLowerCase())
{
console.log("*********************")
for(i = 0; i < toDoList.length; i++){
console.log(`${i}:${toDoList[i]}`)
}
console.log("*********************")
}
else if (input === "delete")
{
let deletedIndex = parseInt(prompt("Which Index Would You like to Delete?"));
const deleted = toDoList.splice(deletedIndex, 1)
console.log(`${deleted} has been Deleted`)
}
input = prompt("What Would You Like to Do")
}
console.log("Ok You Quit");
Someone pointed out in your comments that the code is messy. I cleaned the code and now it is working fine.
let toDoList = [];
var input = prompt("What Would You Like to Do");
while (input != 'quit') {
if (input == "new") {
var addAToDo = prompt("What Would You Like to Add?");
toDoList.push(addAToDo);
console.log(`${addAToDo} added to the list!`);
} else if (input == "list") {
console.log("*********************");
for (i = 0; i < toDoList.length; i++) {
console.log(`${i}:${toDoList[i]}`);
}
console.log("*********************");
} else if (input == "delete") {
let deletedIndex = parseInt(prompt("Which Index Would You like to Delete?"));
const deleted = (toDoList).splice(deletedIndex, 1);
console.log(`${deleted} has been Deleted`);
} else {
void(0);
}
input = prompt("What Would You Like to Do")
}
console.log("Ok You Quit");