title: Solving a 4x4 (simplified one) sudoku in javascript
body: <p>I have a problem where I have to code an automatic solution to a given sudoku which is 4x4 which means the numbers go only as far 1 2 3 4. It's a simplified version of a sudoku since I am still new to programming. </p>
  
  <p>I have a given template with random sudoku generated from it and I have to write a code to solve the sudoku automatically.<br>
  Here is what I have in the begining as sudoku that i have to solve  </p>
  
  <pre><code>sudoku[6] = [[" ","2"," "," "],
               [" "," ","2"," "],
               [" "," "," ","3"],
               ["4"," "," "," "]
  </code></pre>
  
  <p>My idea was to insert "1234" into empty " " and then remove the numbers from "1234" when one of the numbers is already present in the column, row and quadrant. So what I wanted to do is with the use of loops go through all the positions in the tables and the moment I find for example "1" alone i will remove the 1 from "1234".  </p>
  
  <p>Here is the beggning of my code, it appears it doesnt work the moment I reach if, can you guys please tell me what I am doing wrong or why isn't it working when i get to my If. 
  Thank you in advance.</p>
  
  <pre><code>var sudoku = sudoku[6];
  
  // function to put "1234" into empty space ""
  var concatenate = function (s)
  { 
     for (i=0; i&lt;s.length; i++)
         for (j=0; j&lt;s.length; j++)
              if (sudoku[i][j] === " ")
                  sudoku[i][j] = "1234";
  };
  
  concatenate(sudoku);
  
  // function to solve the sudoku automatically. 
  
  var solve = function (t)
  { 
      for (i = 0; i&lt;t.length; i++)
         for (j=0; j&lt;t.length; j++)
             for (k=j; k&lt;(4+j); k++)
                  if (sudoku[i][j].length === 1)    // this is where it seems to bug, in this if im trying to find the position where we only have one number and not "1234"
                      var s = sudoku[i][j];
                  if (sudoku[i][k-j] !== ("1" || "2" || "3" || "4"))  // here im finding the position of all position in the sudoku where ive got "1234" so i can remove the number found in the previous if.
                      {
                          var index = sudoku[i][k-j].indexOf(s);
                          var string_new = sudoku[i][k-j].substring(0,index) + sudoku[i][k-j].substring(index+1, 4);
                          sudoku[i][k-j] = string_new; 
                      }
  };
  </code></pre>