JSFiddle - React, Tailwind, and code Playground

by JakobJingleheimer

JavaScript

var Utils = function () {
    return {
        "toCamelCase": function (str) {
            return str.replace(
                /[\x2D ]\w/g,
                function (txt) {
                    return txt.charAt(1).toUpperCase();
                }
            );
        },
        "fromCamelCase": function (str) {
            return str.replace(/([A-Z])/g, " $1");
        }
    }
};

var utils = new Utils();

console.log( utils.toCamelCase('foo bar') );
console.log( utils.toCamelCase('bar-foo') );
console.log( utils.fromCamelCase('barFoo') );