我的代码中遗漏了什么吗?它似乎只抓取第一个字母,而 while 循环不会进入下一个单词。那么我可能会错过什么?
function acr(s){
var words, acronym, nextWord;
words = s.split();
acronym= "";
index = 0
while (index<words.length) {
nextWord = words[index];
acronym = acronym + nextWord.charAt(0);
index = index + 1 ;
}
return acronym
}
Run Code Online (Sandbox Code Playgroud) javascript ×1