var arr = [1,2,3];
// var newArr = [];
// for (var i = 0; i < arr.length; i++) {
// if (arr[i] > 1) {
// newArr.push(arr[i]);
// }
// }
// console.log(newArr);
// var newArr = arr.filter(item => item > 1);
// console.log(newArr);
var students = [{
name: 'zsl',
age: 18
}, {
name: 'xb',
age: 3
}, {
name: 'xjd',
age: 50
}];
var goods = ['xb', 'zsl'];
// var names = students.filter(item => item.name === 'zsl');
// console.log(JSON.stringify(names))
// var names = [];
// for (var i = 0; i < students.length; i++) {
// names.push(students[i].name);
// }
// console.log(JSON.stringify(names))
// var names = students.map(item => item.name);
// console.log(JSON.stringify(names))
var bads = [];
for (var i = 0; i < students.length; i++) {
var isGood = false;
for (var j = 0; j < goods.length; j++) {
if (students[i].name == goods[j]) {
isGood = true;
}
}
if (!isGood) {
bads.push(students[i]);
}
}
// console.log(JSON.stringify(bads));
var arr1 = [1,2,3]
var item = 2
// console.log(arr1.includes(item))
// var badds = students.filter(item => !goods.includes(item.name))
var badds = students.map(item => item.name).filter(item => goods.includes(item));
console.log(badds)
console