JSFiddle - React, Tailwind, and code Playground

by Frank Liu

JavaScript

function getFileExtension1(filename) {
	try{ 
    const ext = (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename)[0] : false;
    if(ext){
      return ext;
    } else {
      return 'no ext';
    }
  }
  catch(err){
  	return 'exception';
  }
 
}

console.log( getFileExtension1('dfja.txdt.d.d') );