algorithms/truthCheck.js
2024-01-12 07:01:06 -05:00

7 lines
No EOL
237 B
JavaScript

function truthCheck(collection, pre) {
return collection.every(function (user) {
return user.hasOwnProperty(pre) && Boolean(user[pre])
});
}
console.log(truthCheck([{"single": "double"}, {"single": NaN}], "single"));