function pickRandomSquare(state) {
 	//square is value of a square acutally, so only keeping empty squares aka where value is "" == false
 	let emptySquares = state.reduce((previous, current, currentIndex) => {
 		!current && previous.push(currentIndex);
 		return previous;
 	}, []);
 	let randomIndex = Math.random() * emptySquares.length
 	randomIndex = Math.floor(randomIndex);
 	return emptySquares[randomIndex];
 }
/**
 * Simple algorithm to pick a rando empty square
 * 
 * @param  {Array} state List of DomNode that belong to the game grid
 * @return {DomNode}      the selected random dom node that is empty
 */
Simple algorithm to pick a rando empty square

@param  {Array} state List of DomNode that belong to the game grid
@return {DomNode}      the selected random dom node that is empty
Simple algorithm to pick a rando empty square @param { Array } state List of DomNode that belong to the game grid @return { DomNode } the selected random dom node that is empty
function pickRandomSquare(state) {
 	let emptySquares = state.reduce((previous, current, currentIndex) => {
 		!current && previous.push(currentIndex);
 		return previous;
 	}, []);
 	let randomIndex = Math.random() * emptySquares.length
 	randomIndex = Math.floor(randomIndex);
 	return emptySquares[randomIndex];
 }
function pickRandomSquare ( state ) { let emptySquares = state . reduce ( ( previous , current , currentIndex ) => { ! current && previous . push ( currentIndex ) ; return previous ; } , [ ] ) ; let randomIndex = Math . random ( ) * emptySquares . length randomIndex = Math . floor ( randomIndex ) ; return emptySquares [ randomIndex ] ; }
Simple algorithm to pick a rando empty square
Simple algorithm to pick a rando empty square
//square is value of a square acutally, so only keeping empty squares aka where value is "" == false