 <p>Use the <code>replace</code> method:</p> <pre><code>function cap(str) { return str.replace(/([a-z])/, function (match, value) { return value.toUpperCase(); }) } </code></pre> <p><a href="http://jsfiddle.net/tewathia/LuF2e/" rel="nofollow">DEMO</a></p> <p><strong>Edit</strong>: In case you have a string containing multiple (space-separated) words, try something like:</p> <pre><code>function cap(str) { return str.split(' ').map(function (e) { return e.replace(/([a-z])/, function (match, value) { return value.toUpperCase(); }) }).join(' '); } </code></pre> <p>This would convert <code>"50newyork paris84 london"</code> to <code>"50Newyork Paris84 London"</code></p> <p><a href="http://jsfiddle.net/tewathia/LuF2e/1/" rel="nofollow">DEMO</a></p>