Couting Cards javaScript

After one hour or so i have also realized that i the var test is of no use.

can Someone explain to me, why the program aren’t displaing "bet"s and "hold"s at each " cc(card); "?

I am confused, because the program checks just one card at a run, so i think that the output to:
cc(2); cc(3); cc(7); cc('K'); cc('A');

will be:
Bet
Bet
Bet
Bet
Bet
(it means one bet to each card…Because the “if” is inside de function. )

Why it isn’t happing?
I really can’t understand why are displayng the final result with this program.

(sorry my bad english)