New to javascript and I\'m having trouble counting the number of trues in an array of boolean values. I\'m trying to use the reduce() function. Can someone tell me what I\
You should use ++a instead a++ because you have to change the value of a suddenly. a variable will be incremented after its value is returned.
++a
a++
a
value
myCount = [false,false,true,false,true].reduce(function(a,b){ return b? ++a:a; },0); alert("myCount ="+ myCount);