Suppose a binary array var arr = [true, true, false];.
Is there any way to get the AND or OR of the whole array using one method?
You could use Boolean as callback for
OR with Array#some or for
AND with Array#every.
var array = [true, true, false];
console.log(array.some(Boolean)); // or
console.log(array.every(Boolean)); // and
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With