Hi wander,
try the below modifed js code.
//If you want to choose the folder location and save the file. Use the below line.
var myFolder = Folder.selectDialog(); //You want default location use the below line.
var myFolder = "~\Desktop";
var myDoc = app.activeDocument;
var myDocname = myDoc.name.split(".indd");
myDoc.exportFile(ExportFormat.PDF_TYPE, File(new File(myFolder+"\\" + myDocname.join(".pdf"))));
thx,
csm_phil