function countFactors(num) { var finalEnd = num/2; var count = 1; for(var i=1; i<=finalEnd; i++) { if(num%i==0) { count++; } } return count; } console.log(countFactors(24));