Well, I'm very confused about why that code is written that way.
First of all wouldn't it be better to count the commas first, if you've decided it's necessary to do that? As it is your for-loop executes the if-else block once for each character in the input
string instead of just once. Maybe you put the closing brace way down at the end by accident.
Not that it really matters, the last execution of the if-else block will occur when the last character in the input string is processed, so the comma count will be correct then, but it's kind of pointless to do it the way you posted.
As for the if-else block itself, you've got the tests in the wrong order. If commas is equal to 3 then it's less than 4, right? So which branch is executed?