alankis

Comparasion

Oct 7th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getFileExtension(i) {
  2.    
  3.     // i will be a string, but it may not have a file extension.
  4.     // return the file extension (with no period) if it has one, otherwise false
  5.    if(i.indexOf(".") > 0) {
  6.        return i.slice(i.indexOf(".") + 1, i.length);
  7.    } else {
  8.        return false;
  9.    }
  10. }
  11.  
  12. // here we go! Given a filename in a string (like 'test.jpg'),
  13.  
  14. getFileExtension('pictureofme.pdf');
Advertisement
Add Comment
Please, Sign In to add comment