title: why for loop is executing infinite times
body: <pre><code> window.TicTacToet.compMove = function (row, col) {
       var player = window.TicTacToet.PlayerTurn;
       var board = window.TicTacToet.Board;
       for (i = 0; i &lt; window.TicTacToet.Board.length; i++) {
           for (j = 0; j &lt; window.TicTacToet.Board[i].length; j++) {
               if (window.TicTacToet.Board[i][j] == null) {
                   getWin(row, col, player, board);
               } else {
                   console.log("position occupied");
               }
           }
       }
   }
  
   function getWin($r, $c, $player, $board) {
       checkTop($r, $c, $player, $board);
   }
  
   function checkTop($x, $y, $player, b) {
       console.log("ENTER");
       var success = false;
       for (i = 0; i &lt; 3; i++) {
           $x--;
           if ($x &lt; 0) {
               return success;
           }
           if (b[$y][$x] != $player) {
               return success;
           }
       }
       success = true;
       return success;
   }
  </code></pre>
  
  <p>The function check-Top is executing infinite times. The parameters row and col are co-ordinates of the table. Player will return true or false and the board is an array having 9 elements. Both window.TicTacToet.Board.length and window.TicTacToet.Board[i].length have value 9 , i.e 9 x 9 .The console.log("ENTER") should execute 91 times but it is executing infinite times.what may be the reason for this. Because of this all other functions are not working properly, game itself not playing.Please Help out. This is for 9 x 9 clickable board drawing game.</p>