can't convert undefined to object in javascript
<p>Update: I have added the fiddle. Please refer <a href="http://jsfiddle.net/fPVaJ/" rel="nofollow">here</a>. use web console for error.</p>

<p>I am writing a code for traveling salesman problem. Here is the code :</p>

<pre><code>var ind =[];      //values selected 
var cp =[];
var X;
var Y;
var tour = [];


// no values selected in the starting
for(j=0;j&lt;friends_cnt;j++) {
  ind[j] = 0;
}


// distances at i,i infinity
for(i=0;i&lt;friends_cnt;i++) {
  distance[i][i] = 9999999999999;
}

var k = 0;
var X = 0;

tour[k] =  X;
ind[X] = 1;


var i =1;
while(i&lt;friends_cnt &amp;&amp;  ind[i] === 0) {
  var min = 9999999999999;

    // finding minimum of the undeleted values
    for(j=0;j&lt;friends_cnt;j++) {
      if(ind[j] === 0) {
        if(distance[X][j] &lt; min) {
          min = distance[X][j];
          Y = j;  // y is the min city
        }
      }
    }


    k = k+1;               // counter for the starting city
    tour[k] = Y;           //city added
    ind[Y] = 1;            

   X = Y;
   i++;
}

k = k+1;
tour[k] = tour[1];

for(var q=0;q&lt;k+1;q++) {
  console.log(tour[q]);
}

});
});
</code></pre>

<p>now here whenever i run my program, it shows an error  </p>

<p><code>TypeError: can't convert undefined to object</code></p>

<p>in the line </p>

<pre><code>var min = 9999999999999; 
</code></pre>

<p>My question is that is this because JavaScript cant handle large numbers or something else ?</p>
