Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

438
Views
Javascript Code Executes Correctly in browser but receiving multiple "Declaration or statement expected" errors at end of code in VSCODE

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");

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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");

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!