CSS implementation:

text-transform:capitalize;

JS Code 1:

String.prototype.firstUpperCase = function(){
        return this.replace(/\b(\w)(\w*)/g,function($0,$1,$2){
            return $1.toUpperCase() + $2.toLowerCase();
        })
}
var result = "i'm hello world".firstUpperCase();;
console.log(result); //I'M Hello World

Note: Regular expressionb will split the English abbreviation, such as I’m into two parts, resulting in the output of I’M, sob cannot be used.

JS Code 2:

String.prototype.firstUpperCase = function(){
    let arr = this.split(' ');
    let uppserCase = ([first,...rest]) => first.toUpperCase() + rest.join('');
    let result = '';
    arr.forEach((val) => {
        result += uppserCase(val) + ' ';
    })
    return result;
}
// Results: //I'm Hello World

JS Code 3:

String.prototype.firstUpperCase = function(){
    let arr = this.split(' ');
    let result = '';
    arr.forEach((val) => {
        result += val.charAt(0).toUpperCase() + val.slice(1) + ' ';
    })
    return result;
}
// Results: //I'm Hello World

JS Code 4:

String.prototype.firstUpperCase = function(){
    let arr = this.split(' ');
    let result = '';
    arr.forEach((val) => {
        result += `${val[0].toUpperCase()}${val.slice(1)} `;
    })
    return result;
}
//Result: // I'm Hello World

Note:
\bMatching a word boundary, that is, the position between the word and the space. For example, ‘Erb’ can match ‘er’ in ‘never’, but not ‘er’ in ‘verb’.
\wMatch any word character that includes an underscore. Equivalent to'[A-Za-z0-9_]’.
*Match the previous subexpression zero or more times. For example, Zo can match “z” and “zoo”. Equivalent to {0,}.
\sMatch any blank characters, including spaces, tabs, page breaks, etc. Equivalent to [fnrtv].
\SMatch any non-blank characters. Equivalent to [^ f n r t v].

Question Reference Address: Implementation of Uppercase for JavaScript String Words