function handleWin(board) {
    var winStates = [
      [0, 1, 2], [3, 4, 5], [6, 7, 8],
      [0, 3, 6], [1, 4, 7], [2, 5, 8],
      [0, 4, 8], [2, 4, 6]
    ]
    for (var i = 0; i < winStates.length; i++) {
      var winstate = winStates[i];
      if (board[winstate[0]] === piece
        && board[winstate[1]] === piece
        && board[winstate[2]] === piece) {
        setEnd(true)
        return true
      }
    }
    return false
  }
//Setting the states when some one wins

Setting the states when some one wins
Setting the states when some one wins
function handleWin(board) {
    var winStates = [
      [0, 1, 2], [3, 4, 5], [6, 7, 8],
      [0, 3, 6], [1, 4, 7], [2, 5, 8],
      [0, 4, 8], [2, 4, 6]
    ]
    for (var i = 0; i < winStates.length; i++) {
      var winstate = winStates[i];
      if (board[winstate[0]] === piece
        && board[winstate[1]] === piece
        && board[winstate[2]] === piece) {
        setEnd(true)
        return true
      }
    }
    return false
  }
function handleWin ( board ) { var winStates = [ [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ] , [ 0 , 3 , 6 ] , [ 1 , 4 , 7 ] , [ 2 , 5 , 8 ] , [ 0 , 4 , 8 ] , [ 2 , 4 , 6 ] ] for ( var i = 0 ; i < winStates . length ; i ++ ) { var winstate = winStates [ i ] ; if ( board [ winstate [ 0 ] ] === piece && board [ winstate [ 1 ] ] === piece && board [ winstate [ 2 ] ] === piece ) { setEnd ( true ) return true } } return false }
Setting the states when some one wins
Setting the states when some one wins