JSFiddle - React, Tailwind, and code Playground

JavaScript

function shorten(str) {
    return str.slice(0, (function() {
        for (var i=str.length; i--;) {
            if (str.charAt(i).match(/[A-Z]/)) return ++i;
        }
    })())
}

console.log( shorten('FirstName') )
console.log( shorten('Lastname') )
console.log( shorten('BlinK333') )
console.log( shorten('Something Wicked') )