有人可以告诉我为什么这不起作用吗?我已经尝试了很多改变结构,但我放什么似乎并不重要,当应用 if else 语句时,它停止工作。
function wordSplit(){
var sentence = document.getElementById("two").value;
var userWords=sentence.split(" ");
while(t<userWords.length){
alert(userWords[t]);
t++
};
x = 0;
for (var x = 0; x < userWords.length; x++){
y = 0;
for (var y = 0; y < vocab.length; y++){
if (y<vocab.length) {
alert("y is less than vocab")
};
else if (vocab[y] == userWords[x]){
alert("y is equal to x")
};
else if(y<vocab.length) {
alert("y is less than vocab 2")
};
else if (y == vocab.length){
alert(" y is equal to vocab length")
};
else if (y == 0)
{
alert("y is equal to zero)
};
};
};
};