题解 | #将字符串转换为驼峰格式#
将字符串转换为驼峰格式
https://www.nowcoder.com/practice/2ded24e34ec34325a62d42d0c8479bae
function cssStyle2DomStyle(sName) { // 填写JavaScript if(sName[0]==='-'){ sName=sName.substring(1,sName.length) } let arr=sName.split('-') let result=arr[0] for(let i=1;i<arr.length;i++){ let res=arr[i].slice(0,1).toUpperCase()+arr[i].slice(1) result=result+res } return result }