The directory all my files are in is: '/usr/home/jordan' and I have many files under there (in the directory itself, but one file that is named with a .txt extension.
With nodejs and fs, I want to put that first file (or any file) with a txt extension into "mytxtfilepath". I only have a single .txt file in the whole directory (amongst many other files but with different extensions) The single .txt file could be named ANYTHING, I cannot guarantee what the name will be at any given time, only that it ends in .txt:
var homedir = "/usr/home/jordan";
var mytxtfilepath=homedir + "???????";
fs.readfile(mytxtfilepath, function(err,data) {
console.log(data);
});
How do I put the correct path to my txt file without hardcoding the name of the txt file itself?