当字符串包含数组中的元素时,如何使条件成立? Node.js的

时间:2018-03-11 02:17:57

标签: arrays node.js string if-statement include

当消息包含数组中的元素后跟“你在做什么”时,如何使控制台打印为真

示例:

message = 'hi, where are you doing' //false

message = 'hi, what are you doing' //true

message = 'hi, wat are you doing' //true

message = 'hi, are you doing what' //false

const array = ['what', 'wat', 'wut']

if (message.includes(array + ' are you doing')) {
  console.log(true)
}

1 个答案:

答案 0 :(得分:0)

Array.some,如果数组中的一个元素满足您提供的功能,它将返回const getCurrencyLatestInfo = function(currency) { return new Promise(function(resolve, reject) { request('https://min-api.cryptocompare.com/data/price?fsym='+currency+'&tsyms='+currency+',USD', { json: true }, (err, res, body) => { if (err) { reject(err); } else { var result= body; resolve(result); console.log("RESULT: ",result.USD); } }); })

true