Skip to content

Instantly share code, notes, and snippets.

@paxperscientiam
Created February 15, 2019 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paxperscientiam/4e5e8f676bea64e9dcbbfe6b68c69c95 to your computer and use it in GitHub Desktop.
Save paxperscientiam/4e5e8f676bea64e9dcbbfe6b68c69c95 to your computer and use it in GitHub Desktop.
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1)
}
String.prototype.toTitleCase = function() {
const arrSentence = this.toLowerCase().split(" ")
arrSentence.forEach((word, index, arr) => {
if (word.length > 3) {
arr[index] = word.charAt(0).toUpperCase() + word.slice(1)
}
})
return arrSentence.join(" ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment