JavaScript implementation of the bowling score problem