【发布时间】:2011-04-12 14:42:33
【问题描述】:
大家好,我一直在创建一个小聊天机器人(为了好玩和练习)。
我的以下功能无法正常工作 (FULL CODE HERE):
function runAI() {
if (i.val().length > 0) {
if ($.inArray(i.val(), helloInputArray)) {
r = Math.floor(Math.random()*4);
o.html(o.html()+helloOutputArray[r]);
i.val('');
i.focus();
} else if ($.inArray(i.val(), byeInputArray)) {
r = Math.floor(Math.random()*4);
o.html(o.html()+byeOutputArray[r]);
i.val('');
i.focus();
} else {
o.html(o.html()+"I don't know what that means...<br />");
i.val('');
i.focus();
}
}
}
它似乎总是返回helloOutputArray...
【问题讨论】:
标签: javascript jquery