Convert string to camel case - Node.js String

Node.js examples for String:Case

Description

Convert string to camel case

Demo Code


/**// w  ww  .  j  a  v  a  2  s.  com
 * @param {string} str
 * @return {string} str
 */
function toCamelCase(str) {
    return str.toLowerCase().replace(/-(.)/g, function(match, group1) {
        return group1.toUpperCase();
    });
}

Related Tutorials