JSFiddle - React, Tailwind, and code Playground
by Nick Craver
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
hello
JavaScript
function toPascalCase(str) {
var arr = str.split(/\s|_/);
for(var i=0,l=arr.length; i<l; i++) {
arr[i] = arr[i].substr(0,1).toUpperCase() +
(arr[i].length > 1 ? arr[i].substr(1).toLowerCase() : "");
}
return arr.join("");
}
alert(toPascalCase("hello"));
alert(toPascalCase("HELLO"));
alert(toPascalCase("hello_world"));
alert(toPascalCase("HELLO_WORLD"));
alert(toPascalCase("Hello World"));