参考答案:
代码语言:javascript复制var string = "get-element-by-id";
function combo(msg) {
var arr = msg.split("-"); //split("-")以-为分隔符截取字符串,返回数组
for (var i = 1; i < arr.length; i ) {
arr[i] = arr[i].charAt(0).toUpperCase() arr[i].slice(1);
}
msg = arr.join(""); //join()返回字符串
return msg;
}
console.log(combo(string));