Help with debugging code in App Lab

My student built a blackjack game. The first round executes correctly, but when the 2nd round plays, and the “hit” button is used, it brings up two cards instead of one, and when the 3rd round plays, the “hit” button brings up 3 cards instead of one, and etc. We ran the debugger, and the counts reset, but it seems that the code that executes draw the card (called “draw” in the program) runs twice and again three times for the 3rd round. Here is the link. Any help is appreciated.

I think the problem is that the onEvents for “hitButton” and “standButton” are inside the function startGame(). Every time you call startGame() I think it’s creating a new event and those aren’t going away.

I moved them out and I think it’s working OK. Check it out here: https://studio.code.org/projects/applab/t2jVhDeu6PVZc8xDRt3FOXuQmRVJ1qZnErCK8qJtg_Y

P.S. I didn’t look at the timing – sometimes starting a timer in a function that’s called repeatedly sets multiple timers…