必須調試這個類的某段代碼,我不知道爲什麼這個JS計算所有字母而不僅僅是元音。爲什麼此代碼不僅計算元音?
var text, i, sLength, myChar;
var count;
var text = prompt("Type a phrase please"); //put var in front of text and fixed " in place of ' in front of type
count = 0;
for (i = 1; i <= text.length; i+= 1){
myChar = text[i];
if (myChar == 'a' || 'o' || 'e' || 'u'){ //switched to the proper vowels
count += 1;
console.log('Vowel:', myChar);
}
console.log(myChar, count);
}
alert (count); //put the count in() instead of alert
myChar == '一個' || myChar =='o'... – 2015-05-29 04:21:21
...你錯過了'我' – 2015-05-29 04:22:25