我有一个包含的数组
const submissions = [{
question: 'blah blah blah blah',
response: 'response goes here'
},
我有一个接受提交数组和字符串的函数。我需要检查响应提交 [i].response 对字符串。如果存在则返回 true。
let submissions = [{
question: 'blah blah blah blah',
response: 'response goes here'
}];
function checkString(submissions, string) {
for (let i = 0; i < submissions.length; i++) {
if (submissions[i].response === string) {
return true;
}
}
return false;
}
console.log(checkString(submissions,'response goes here'));
如果调用函数 checkString(submissions, 'response goes here') 应该返回 true。这总是返回 false。
哔哔one
慕哥9229398
相关分类