I have 2 functions doing the same thing but for some reason the results are different.
What am i missing? TIA
let arr = [
{first: 'Jules', last:'Atkinson'},
{first: 'Ralf', last:'Benson', isInstructor: true},
{first: 'Quinten', last:'Pottinger'},
{first: 'Linden', last:'Knaggs', isInstructor: true}
]
function getCertainKey1(arr, key) { // gives me FALSE
return arr.every((val) => {
key in val;
});
}
function getCertainKey2(arr, key) { // gives me TRUE
return arr.every(val => key in val);
}
console.log(getCertainKey1(arr, 'first'));
console.log(getCertainKey2(arr, 'first'));