JSFiddle - React, Tailwind, and code Playground

by gabrieleromanato

HTML

<p><a href="#" id="run">Camel Case</a></p>

<div id="test">lorem ipsum</div>

JavaScript

$.extend (String.prototype, {
  camelize: function () {
    return this.replace (/(?:^|[-_])(\w)/g, function (_, c) {
      return c ? c.toUpperCase() : '';
    })
  }
});

$('#run').click(function() {
    var test = $('#test');
    var $str = test.text();
    var parts = $str.split(' ');
    var part = parts[1].camelize();
    
    test.text(parts[0]+part);
    
    return false;
});