How to properly restart the function?

  • 0
    Hello, I wrote my blackjack and ran into a problem: after the hand is over and the winner is determined, the game_end () function is executed, which, in turn, calls game_start () to start a new game, but the new game works crookedly, and generally "stalls" on setTimeout.

    How can I immediately start a new game after the end of a distribution?


    P.S Without SetTimeout, everything works as expected, only minor bugs remain, but its 3 seconds is vital for the project.
    JavaScript Anonymous, Jun 22, 2019

  • 1 Answers
  • 0
    Didn't go into details, but:

    1. game_end should clear the this.inited variable. Therefore, it does not go beyond the timeout.

    2. game_end should clean up event listeners that are hung by game_start

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!