programming-examples/js/String/Convert a string into camel case.js

10 lines
367 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
camelize = function camelize(str) {
return str.replace(/\W+(.)/g, function(match, chr)
{
return chr.toUpperCase();
});
}
console.log(camelize("JavaScript Exercises"));
console.log(camelize("JavaScript exercises"));
console.log(camelize("JavaScriptExercises"));