问题是随机的,但它们表明了我的需要。 你可以看到答案[0],我必须指出三个可能的答案。我希望能够说明答案是正确的,如果“账单”写在答案的任何地方。 但这不起作用
for (var i = 0; i < answer[index].length; i++)
{
for (answer[index][i] in answer_input.text.toLowerCase())
{
correct = true;
}
answer = new Array();
answer[0] = ["your name is bill","bill's your name","your name's bill"]
answer[1] = ["john", "sean", "greg"]
question = new Array();
question[0] = "whats my name?"
question[1] = "whats not my name?"
index = 0;
onEnterFrame = function ()
{
question_txt.text = question[index];
};
enter1.onRelease = function()
{
question_txt.text = question[index];
var correct = false;
for (var i = 0; i < answer[index].length; i++)
{
if (answer[index][i] == answer_input.text.toLowerCase())
{
correct = true;
}
}
if (correct)
{
index++;
answer_input.text = "";
}
else
{
answer_input.text = "Incorrect";
}
};
答案 0 :(得分:0)
如果你想要的只是检查“账单”是否写在答案的任何地方,为什么不使用
answer_input.text.toLowerCase().indexOf( "bill", 0 )
如果“bill”在那里,该函数将返回答案中出现的索引。如果它不在那里,将返回-1。