96
rated 0 times
[
97]
[
1]
/ answers: 1 / hits: 59773
/ 13 Years ago, wed, october 12, 2011, 12:00:00
I'm trying to write a function that converts for example list-style-image
to listStyleImage
.
I came up with a function but it seems not working. Can anybody point me to the problem here ?
var myStr = "list-style-image";
function camelize(str){
var newStr = "";
var newArr = [];
if(str.indexOf("-") != -1){
newArr = str.split("-");
for(var i = 1 ; i < newArr.length ; i++){
newArr[i].charAt(0).toUpperCase();
}
newStr = newArr.join("");
}
return newStr;
}
console.log(camelize(myStr));
More From » arrays