【发布时间】:2018-10-16 14:35:34
【问题描述】:
我创建了这段代码,其中大部分都在使用 toUpperCase 例外,它应该使单词的每个第一个字母大写。没有错误,所以我不确定为什么该方法当前不起作用。为什么会这样。
let str ="insert string here"
String.prototype.toCase = function () {
let arrayWord = str.split("");
for (let i = 0; i<str.length; i++){
if (arrayWord[i]===" "){
arrayWord[i+1].toUpperCase();
}
else{
}
}
let result = arrayWord.join("");
return (result)
};
【问题讨论】:
-
函数的输出是什么?
标签: javascript loops