TIc Tac Toe AI Not Working

Hi everyone, I got my Tic Tac Toe project mostly done, but I wanted to use the MinMax AI, so I followed along with a youtube tutorial :https://www.youtube.com/watch?v=x_Je9i3aKNk

Somehow, it doesn’t seem to work for me, and I’m still learning how to debug. Could anyone please help me out? Or at least point me in the right direction? My code is here:
https://codepen.io/jonnnyk20/pen/brvEYK
The error I get is “Uncaught TypeError: Cannot read property ‘cost’ of undefined”.

Thank you!

Thank you Randell for the thorough explanation. It took me a while but I finally got it working :slight_smile: