I'm trying to create a function that returns a string in camel case capitalizing each letter where there is a hyphen.
i.e. "this-should-be-camel-case" would return "thisShouldBeCamelCase".
I've changed to first letter of each word to capital and removed to hyphen but can't get the completed sentence to return. I've tried playing with substr and substring to no avail, not sure if they're what I want to be using for the task.
What should I be using to return the sentence in camel case ? How do I do this ? Thanks
function camelCaseIt(str) {
for(var i = 0; i < str.length; i++) {
if(str[i] == '-') {
var chgLtr = str[i] = '';
var uprCase = str[i+1].toUpperCase();
}
}
return str;
}
alert(camelCaseIt('this-should-be-camel-cased'));