How to Check If All Values in Array are True in JavaScript
How can we check if all values in an array are true
in JavaScript?
Suppose we’re working with an array of boolean values.
const arr = [true, true, false];
Check all values are true
with every()
We can check if all values are true
using every()
.
arr.every(v => v === true)
arr.every(Boolean)
Check all values are true
with includes()
Or, we can check if the array includes a false
value.
!arr.includes(false)