Javascript String capitalizeFirstLetter(exceptions)

Description

Javascript String capitalizeFirstLetter(exceptions)


String.prototype.capitalizeFirstLetter = function (exceptions) {

    var str = this.split(' ');

    for (var i = 0; i < str.length; i++){

        if (exceptions.indexOf(str[i]) != -1) {
            continue;//  www  .  j ava 2 s .com
        }

        str[i] = str[i].split('');
        str[i][0] = str[i][0].toUpperCase();
        str[i] = str[i].join('');
    }

    return str.join(' ');
};



PreviousNext

Related