getFileExtension

getFileExtension in JS

by jdcravens

JavaScript

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('.') !== -1){
        return i.split('.').pop();
    }else{
        return false;
    }
    
}

console.log('getFileExtension: ' + getFileExtension('string.jpg'))