Stuck in tic tac toe!

HI kind person,

This may take you a minute (hopefully not)

I’m stuck with my tic tac toe front end project. I am using minMax it’s recursive. The link to my codepen is at the bottom.

My questions revolve around the function score, which does all the heavy lifting.

  1. When I have score return the best score, I believe it’s just giving me the last score not the best score.

  2. The tally array in the func score is also not one array but instead is redefined every time I run the recursion. I understand why recursion does this. However, I do not understand why tally, which should be an array of scores for each possible board, is not one array but many redefined arrays. Shouldn’t the recursion have completed by then?

  3. If the recursion should not have completed and tally with it’s many definitions is correct and I am just wrong. Then how is bestScore (also in score) going through the different possibilities and picking the best one?

  4. If instead I have the function Score return the best possible move (in the form of a new board) it returns undefined, what’s up with that?

Thank you so much I really appreciate it, I’ve been stuck down here for what seems like forever,

link to codepen:


1 Like