题解 | #将字符串转换为驼峰格式#
将字符串转换为驼峰格式
https://www.nowcoder.com/practice/2ded24e34ec34325a62d42d0c8479bae
function cssStyle2DomStyle(sName) { let arr = sName.split("-"); if(!arr[0]){ arr.splice(0,1); } let html = ""; for(var i =0;i<arr.length;i++){ if(i==0){ html = arr[i]; } if(i>0){ html += arr[i].substr(0,1).toUpperCase()+arr[i].substr(1); } } return html; }