const deleteTodo = (title) => {
    try {
    // read from the todos.json if it exists
     const todoBuffer = fs.readFileSync("todos.json");
     // convert it to string
     let dataJSON = todoBuffer.toString();
     // parse the data
     const todos = JSON.parse(dataJSON);
    
     const remain = todos.filter((item) => {
         return item.title != title;
     })

     dataJSON = JSON.stringify(remain);

     fs.writeFileSync("todos.json", dataJSON);

     if (remain.length === todos.length){
         console.log("This file does not exist")
     }else{
         console.log("Todo was deleted succesfully")
     }
    }catch(error){
        console.log("An error just occured")
    }
}