Created
August 13, 2018 20:36
-
-
Save BorisKotlyarov/788b34de05298836d4b3276281938ab0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.toCapitalize = function () { | |
let arr = this.toLowerCase().split(" "); | |
arr.forEach((item, index) => { | |
arr[index] = item[0].toUpperCase() + item.substr(1); | |
}); | |
return arr.join(" "); | |
} | |
let string = `hello world! this is TEST string`; | |
console.log(string.toCapitalize()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment