// using string methods only filename.substring(0, filename.lastIndexOf('.')) || filename // using both string & array methods filename.split('.').slice(0, -1).join('.')