Sudoku boxes count JavaScript I'm creating Sudoku in JS but can't find the way to extract the numbers from the squares. The numbers from the rows and columns are easy to extract but I can't find the way around the squares. According to users input, I'll validate the column, then the row and finally the squares to see if the numbers are being repeated. Is this best practice?

Globals: 

 var numIni = 9; //Number of squares per side;
 var squared = Math.sqrt(numIni); // I'll need this.


Column check:

function getColumn(){
var num = 30; //USER's INPUT
var colNums = []; //numbers IN the column
var countCol = num; // column anchor
while(countCol &gt; numIni ){
    countCol -= numIni      
}
colNums[0] = countCol;

for(i=1;i&lt; numIni;i++){     
    colNums[i]= colNums[i-1]+9;
 }  
}


Row check:

function getRow(){
var num = 50; //USER's INPUT
var rowAnchor = (Math.ceil(num/numIni))*numIni-(numIni-1);

var rowNums=[rowAnchor]//numbers IN the row

for(i=1;i&lt; numIni;i++){     
    rowNums[i]= rowAnchor+i;
}


}


These last two work, but the squares are killing me. I'm first extracting the anchors, then building the squares and validating the number against that. It's getting quite long. Is there a better way to write this? Is the logic inefficient? If it's right, I'm stuck anyway.

Squares check (so far):

function getSquare(){
var boxes = []; 
var boxesAnchor = []; 
boxes[0]=1;
boxesAnchor[0]=1;

for(i=0; i&lt; numIni*numIni ; i++){
    boxes[i]= squared + ((i-1)* squared )+1;
    }

for(i=0; i&lt; numIni*squared ; i++){
   for(j=0; j&lt; squared ; j++){ 
      boxesAnchor[i] = boxes[i];
      boxesAnchor[i+j] = boxes[i+j];
      boxesAnchor[i+j] = boxes[i+j];
   }
  i +=(numIni-1);  
}

boxesAnchor.clean(undefined);// method added to the Array object

}
As we know, the numbers that could be placed in sudoku cells are limited (1..9). So we can easily make an index to existence of 1 through 9 in each row, column and square.
Consider we use rowIndex[9][10], colIndex[9][10] and sqrIndex[9][10] for this purpose. Now checking that putting value v in row x and column y would be like below:

if ( rowIndex[x][v] ) return FAILURE;
if ( colIndex[y][v] ) return FAILURE;
var sqrID = (x/3)*3 + (y/3);
if ( sqrIndex[sqrID][v] ) return FAILURE;
return SUCCESS;


and if SUCCESS is returned we can put that value in the specified cell and update our maps:

rowIndex[x][v] = colIndex[y][v] = sqrIndex[(x/3)*3+(y/3)][v] = 1;


P.S: sqrIndex address all squares in row major.