Use the sign function the values of which you can use in your switch statement:
// Array of Numbers
var nums = new Array(-13,2,67,3,0,56,12,-41);
var len = nums.length;
var positives = 0;
var negatives = 0;
var zeroes = 0;
for (i=0; i<len; i++) {
counter(num[i];
}
// Here you need to output the values positives, zeroes and negatives to show which one occurred how many times
//Create counter function
function counter(number) {
var sign = (number > 0) ? 1 : (number < 0) ? -1 : 0;
switch (sign) {
case 1:
positives++
break;
case 0:
zeroes++;
break;
case -1:
negatives++;
break;
};
Regards,
ā Manfred
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian