JavaScript数组:检查多个值
我们需要编写一个JavaScript函数,该函数接受两个Numbers数组,并检查第一个数组的所有元素是否存在于第二个数组中。
示例
为此的代码将是-
const arr1 = [34, 78, 89];
const arr2 = [78, 67, 34, 99, 56, 89];
const multipleIncludes = (first, second) => {
const indexArray = first.map(el => {
return second.indexOf(el);
});
return indexArray.indexOf(-1) === -1;
}
console.log(multipleIncludes(arr1, arr2));输出结果
控制台中的输出-
true
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短