0
0
Fork 0

Extend the String prototype to allow easier title casing.

This commit is contained in:
Tyler-A 2020-07-06 23:36:30 -06:00
parent fb58e20f7a
commit 72bbaadfba

10
js/prototypes.js vendored Normal file
View file

@ -0,0 +1,10 @@
String.prototype.toTitleCase = function () {
let words = this.split(` `);
let new_words = [];
for (var word of words) {
new_words.push(
`${word[0].toUpperCase()}${word.slice(1).toLowerCase()}`
);
};
return new_words.join(` `);
}