To count the number of true values in an array of boolean values with JavaScript, we call the filter method.
For instance, we write
const arr = [true, false, true, false, true];
const count = arr.filter(Boolean).length;
to call arr.filter with Boolean to return an array with the truthy values in arr in a new array.
Then we get the count of that with the length property.