I'm having an Array with properties id
and value
var arrayObj= [
{id: 1, value: true},
{id: 2, value: false},
{id: 3, value: true}
]
I need to get the number of objects that has the property true
/false
.
I'm using Array.prototype.every()
but my logic is not working as intended as it seems. Can anyone tell me what I'm doing wrong here? I'm not displaying the count
function checkIfFalse(value, index, ar) {
document.write(value + );
if (value === false)
return true;
else
return false;
}
if (arrayObj.every(checkIfFalse)) {
console.log(all are false);
}else {
console.log(all are true);
}