var _ = require('lodash');
var users = [
{ 'id': '1', 'coins': false },
{ 'id': '2', 'coins': false }
];
var a = _.every(users, function(p){
if ('id' in p && 'coins' in p)
return true;
else
return false;
});
console.log(a);
The function works to check in keys exists in an array of objects. If one of the object doesn't exists "id" or "coins" , it return false.
Is there a better way to write thie snippet of code? I felt quite clumsy.