'use strict';
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
String.prototype.titleize = function() {
var string_array = this.split(' ');
string_array = string_array.map(function(str) {
return str.capitalize();
});
return string_array.join(' ');
}
var str = 'this is not a title yet'.titleize(); // It is now
A port of rails String#titleize function, can probably be helpful in your node.js applications :)
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.