Slightly generalized implementation of tic tac toe in javascript.