Naughts and Crosses in javascript