Javascript Titleize function

'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 = { 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

It's not a complete port, you forgot to convert underscores to spaces

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.