Created
February 15, 2019 19:56
-
-
Save paxperscientiam/4e5e8f676bea64e9dcbbfe6b68c69c95 to your computer and use it in GitHub Desktop.
This file contains 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.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