当消息包含数组中的元素后跟“你在做什么”时,如何使控制台打印为真
示例:
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)
}
答案 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