Tic tac toe almost done!

Hey, after lot of thinking,questioning I came up with this code.The machine tries to either win or draw the game and the probablity for a user to win is less.If two of the users pieces are in same row/column the computer occupies the third place( and for this I used if else condition)
I know the code can be optimized and any suggestions from your side will be benificial.


the link : http://codepen.io/Copperpd/full/LWVPqW