我想返回字符串「布萊恩·韋德棧」, 下面的代碼:titleCasing沒有返回正確的答案
var fixName = function(myName) {
var partsOfName = [
part1 = myName.substring(0, 5),
part2 = myName.substring(5, 8),
part3 = myName.substring(9, myName.length)
];
part1 = part1.charAt(0).toUpperCase() + part1.slice(1);
part2 = part2.charAt(5).toUpperCase() + part2.slice(1);
part3 = part3.charAt(9).toUpperCase() + part3.slice(1);
return(part1+" "+part2+" "+part3);
}
var myName= "brianwadestacks"
console.log("My name fixed is " + myName);
它返回我的名字定爲brianwadestacks
您已經定義了一個函數,但沒有在任何地方調用它。你也有一個語法錯誤(在'myName'之後加''''''''''''''''''''''''') – meagar
@meagar謝謝! –
所以不是調用myName,而是調用fixName? –