Updated with a little bit smarter com

I have ported my small game made in HyperApp to React recently. It is a Tic Tac Toe game. Supported human player against the computer. However the com
player simply choose any unmarked block randomly. That makes quite an easy win for human player.
So, for the sake of experiment, I have updated the computer to be little bit hard to be defeated. Here is the updated version, https://codepen.io/mjunaidi/pen/OOpaBq.
What I have done is specifically for the computer to choose;
- Any block that could make
com
win, or - Any block that could prevent
p1
from winning, or - Choose any block randomly.
For the third option, this could be improved further. Like creating a little bit of strategy for example. That's why I think by creating a machine learning system will solve all of this issues. By training the computer to choose the blocks by making it to learn from thousands of game sets.
Thanks for reading!