Fabulous article demonstrating how to write a chess AI, including several interactive demos!
https://medium.freecodecamp.org/simple-chess-ai-step-by-step-1d55a9266977
It also shows the importance of a big ecosystem. There are already JS libraries for computing legal moves and showing a chess UI, so you can focus on the AI!