我试图让所有的常量都有旁边的操作,但没有任何工作。 这是这里的JavaScript代码。这段代码我写了什么错?
function opishConversion(text) {
var output = "";
for (var i = 0; i < text.length; i = i + 1) {
if ((text.charAt[i] !== "a") || (text.charAt[i] !== "A") || (text.charAt[i] !== "e") || (text.charAt[i] !== "E") || (text.charAt[i] !== "i") || (text.charAt[i] !== "I") || (text.charAt[i] !== "o") || (text.charAt[i] !== "O") || (text.charAt[i] !== "u") || (text.charAt[i] !== "U")) {
output += text.charAt[i] + "op";
} else {
output += text.charAt[i];
}
}
return output;
}
var text = prompt("Enter Text To Convert");
alert(opishConversion(text));
任何帮助,将不胜感激。
你的意思是辅音,对不对?如在非元音字母中?常量!=辅音 – 2014-11-14 19:14:43
您需要提出一个问题来解决特定问题,并避免过于宽泛的问题,例如“我做错了什么?” – 2014-11-14 19:22:28
整个函数可以用'text.replace(/([^ aeiou])/ gi,“$ 1op”)' – 2014-11-14 19:23:54