function validSolution(board){

  var checker = [1, 2, 3, 4, 5, 6, 7, 8, 9];


  //check rows

  for(var i=0; i<board.length; i++){
    var row = board[i].slice().sort();

    for(var j=0; j< row.length; j++){
      if(row[j] !== checker[j]){
        return false;
      }
    }
  };



  //check columns

  for(var k=0; k<board.length; k++){

    var column = [];

    for(var q=0; q< board.length; q++){
      column.push(board[k][q]);

    }

    column.sort();

    for(var r=0; r< column.length; r++){
      if(column[r] !== checker[r]){
        return false;
      }
    }
  }

  //check blocks

    //loop through blocks vertically
  for(var a=0; a<9; a+=3){

    //loop through blocks horizontally
    for(var c=0; c<9; c+=3){
       var block = [];
      //loop through rows within each block
      for(var b=a; b<(3+a); b++){
        
        //loop through columns within each block row

        for(var d=c; d<(3+c); d++){

          block.push(board[b][d]);

        } 

      }

      block.sort();
      for(var s=0; s< block.length; s++){
        if(block[s] !== checker[s]){
          return false;
        }
      }

    }

  }

  return true;

}
//A winning game has each of 1-9 in each row, each column and each 3x3 block.
A winning game has each of 1-9 in each row, each column and each 3x3 block.
A winning game has each of 1 - 9 in each row each column and each 3x3 block .
function validSolution(board){
  var checker = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  for(var i=0; i<board.length; i++){
    var row = board[i].slice().sort();
    for(var j=0; j< row.length; j++){
      if(row[j] !== checker[j]){
        return false;
      }
    }
  };
  for(var k=0; k<board.length; k++){
    var column = [];
    for(var q=0; q< board.length; q++){
      column.push(board[k][q]);
    }
    column.sort();
    for(var r=0; r< column.length; r++){
      if(column[r] !== checker[r]){
        return false;
      }
    }
  }
  for(var a=0; a<9; a+=3){
    for(var c=0; c<9; c+=3){
       var block = [];
      for(var b=a; b<(3+a); b++){
        for(var d=c; d<(3+c); d++){
          block.push(board[b][d]);
        } 
      }
      block.sort();
      for(var s=0; s< block.length; s++){
        if(block[s] !== checker[s]){
          return false;
        }
      }
    }
  }
  return true;
}
function validSolution ( board ) { var checker = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ; for ( var i = 0 ; i < board . length ; i ++ ) { var row = board [ i ] . slice ( ) . sort ( ) ; for ( var j = 0 ; j < row . length ; j ++ ) { if ( row [ j ] !== checker [ j ] ) { return false ; } } } ; for ( var k = 0 ; k < board . length ; k ++ ) { var column = [ ] ; for ( var q = 0 ; q < board . length ; q ++ ) { column . push ( board [ k ] [ q ] ) ; } column . sort ( ) ; for ( var r = 0 ; r < column . length ; r ++ ) { if ( column [ r ] !== checker [ r ] ) { return false ; } } } for ( var a = 0 ; a < 9 ; a += 3 ) { for ( var c = 0 ; c < 9 ; c += 3 ) { var block = [ ] ; for ( var b = a ; b < ( 3 + a ) ; b ++ ) { for ( var d = c ; d < ( 3 + c ) ; d ++ ) { block . push ( board [ b ] [ d ] ) ; } } block . sort ( ) ; for ( var s = 0 ; s < block . length ; s ++ ) { if ( block [ s ] !== checker [ s ] ) { return false ; } } } } return true ; }
A winning game has each of 1-9 in each row, each column and each 3x3 block.
A winning game has each of 1 - 9 in each row each column and each 3x3 block .
//check rows //check columns //check blocks //loop through blocks vertically //loop through blocks horizontally //loop through rows within each block //loop through columns within each block row