【发布时间】:2018-06-07 13:48:45
【问题描述】:
如何在 JavaScript 中做到这一点?当它在big_list 中点击words 时,它应该打印'Found'
big_list = ['this', 'is', 'a', 'long', 'list', 'of' 'words']
needle = ['words', 'to', 'find']
for i in big_list:
if i in needle:
print('Found')
else:
print('Not Found')
我知道一般的 if/else 结构,但不确定语法:
if (big_list in needle) {
console.log('print some stuff')
} else {
console.log('print some other stuff')
}
【问题讨论】:
标签: javascript python arrays list