这是我的功能。它应该返回backgroundColor而不是backgroundcolor.
我的问题是什么?
\nfunction camelize(str) {\n let newStr = str.split(\'-\');\n newStr.forEach((item, index) => {\n if (index > 0) {\n item.toLowerCase();\n item = item[0].toUpperCase() + item.slice(1);\n }\n });\n\n newStr = newStr.join(\'\');\n return newStr;\n}\nconsole.log(camelize("background-color")); //\'background\xd1\x81olor\' instead of \'backgroundColor\'Run Code Online (Sandbox Code Playgroud)\r\n