leave balance javascript