Actually, my script counted all numerical values, regardless of their actual value. To only count positive, non-zero numbers, you’ll have to amend the code this way:
var arr = [1,0,2,5,6,-1,4,5,6,,0,12], i = arr.length,count = i;
while (i--) {
if (isNaN(arr[i])||arr[i]<=0) count--;
}
Watch.Log(count,2);
The result will yield 8 because out of the 12 values, 1 is undefined, 2 are equal to zero and 1 is negative.