ExampleUpdated 03 Feb 2023
Get extension of filename
Example on how to make a function that takes out the extension from a specified filename.
Example
Code Test.hash
#{
function getExt(filename) {
if (!filename) return "";
let parts = filename.split(".");
let extension = parts[parts.length - 1];
return extension.toUpperCase();
}
write(getExt("testing.pdf"));
write("\n");
write(getExt("myfile.docx"));
}# Output
PDF
DOCX