Tic-Tac-Toe with AI - pt 2

In the past week, I received positive and negative feedback on my Tic-Tac-Toe program. The positive was that the AI was unbeatable, the negatives was duplications, global variables (and functions), and coupling of UI and game logic, in addition to not having any tests (yikes). They recommended using Jasmine to test the program and modularity.

The first item I wanted to tackle was duplication. The less code I have, the easier it would be to decouple and scope functions.

Building my first real JS program, I learned that you’re only suppose to have one document.ready block. In my file, I had 9 blocks of code that looked almost identical.

  $(document).ready(function(){ $("#row1 span0").click(function(){ if ($("#row1 span0")[0].innerHTML == "+") { $("#row1 span0")[0].innerHTML =...

Continue reading