我不断收到“类型错误:str.join 不是函数。这段代码应该接受一个字符串输入,并使输入中的每个字母成为下一个字母(即 a->b,z->a)并将每个元音大写. 有谁知道为什么它仍然是错误的?
str = str.split("");//split() string into array
for(var i=0;i<str.length;str++){//for loop that checks each letter
if(str[i].match(/[a-y]/i)){
str[i]=String.fromCharCode(str[i].charCodeAt(0)+1);
}else if(str[i].match('z')){
str[i] = 'a';
}
if(str[i].match(/[aeiou]/i)){
str[i] = str[i].toUpperCase();
}
}
str2= str.join('');
//modifies letter by adding up in alphabet
//capitalizes each vowel
//join() string
return str2;
}
// keep this function call here
// to see how to enter arguments in JavaScript scroll down