题解 | #将字符串转换为驼峰格式#
将字符串转换为驼峰格式
http://www.nowcoder.com/practice/2ded24e34ec34325a62d42d0c8479bae
function cssStyle2DomStyle(sName) { if(/^-/.test(sName)){ sName = sName.slice(1) } let arr = sName.split('-') for(let len=arr.length,i=0;i<len;i++){ if(i>0){ arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].slice(1) } } return arr.join('') }