Counting the Number of Zeroes in a Javascript Array

Scenario
We have this array const a = [0,1,0]
.
We want to count the number of zeroes in it.
Approach
a.filter(v => v === 0).length;
We have this array const a = [0,1,0]
.
We want to count the number of zeroes in it.
a.filter(v => v === 0).length;
Founder of Firefly Semantics Corporation
Love podcasts or audiobooks? Learn on the go with our new app.