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));