Tell us what’s happening:
I am doing the challenge to check all objects in array return true based on second argument. I have tested with logging to console and all parts of code seem to be running correctly but the overall function keeps returning undefined. Can anyone help please?
Your code so far
function truthCheck(collection, pre) {
collection.every ((object, index) => {
if (object.hasOwnProperty(pre)) {
return true;
} else {
return false;
}
});
}
console.log(truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.
Challenge: Everything Be True
Link to the challenge:
