Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getFileExtension(i) {
- // i will be a string, but it may not have a file extension.
- // return the file extension (with no period) if it has one, otherwise false
- if(i.indexOf(".") > 0) {
- return i.slice(i.indexOf(".") + 1, i.length);
- } else {
- return false;
- }
- }
- // here we go! Given a filename in a string (like 'test.jpg'),
- getFileExtension('pictureofme.pdf');
Advertisement
Add Comment
Please, Sign In to add comment