The problem is due to your double loops.
For example: when i=0, j=0 it is not collision between two different balls.
Think about what you were doing and you will understand why it is not working.
You should change the second loop to
for (var j = i; i < howManyBalls; j++)