【发布时间】:2017-12-12 16:43:03
【问题描述】:
我在互联网上找不到我需要的东西,或者我没有使用正确的词,但这是我的问题。
我有一个字符串例如: Ok bot,给我看看 Foo 程序的文档。
还有我的关键字:["bot","doc", "show", "Foo"]
我希望如果字符串包含 3 个或更多关键字,我的函数将返回一条消息,例如
我已经考虑过了
var message = "Ok bot, show me the doc of the Foo program.";
var keywords = ["bot","doc","show","foo"];
if(keywords.indexOf(message) >=3 ){
console.log('ok I understand');
}
但它不起作用
有人可以帮帮我吗?
谢谢
【问题讨论】:
标签: javascript arrays string keyword