Capitalize title page if
<p>I wrote this script to capitalize first letter of title or if URL contains giocatori_ first letters of name until '-' (Giovanni Rossi) but the <strong>if</strong> it doesn't work.</p>

<pre><code>$(document).ready(function(){
    function capitaliseFirstLetter(string){
        if (/giocatore_/.test(window.location)) {
            var title = document.title;
        subTitle = title.split('-')[0];
        subTitleNext = title.split('-')[1];
        subTitle=subTitle.replace('_',' ');

        subTitle = subTitle.toLowerCase().replace(/\b[a-z]/g, function(letter) {
            return letter.toUpperCase();
        })


        document.title = subTitle+' - '+subTitleNext;
    } else {
        return string.charAt(0).toUpperCase() + string.slice(1);
    }
    document.title = capitaliseFirstLetter(document.title);
});
</code></pre>

<p>Any suggestion?</p>

<p>Thanks </p>
