Actually, this small change fixes it:
Code:
 if(arr[j] == str) { 
                arr.splice(j,1); 
                count++; 
            }
to
Code:
 while(arr[j] == str) { 
                arr.splice(j,1); 
                count++; 
            }
Thank you marlopax!