title: Get the shortest way between two point
body: <p>I have the following array:</p>
  
  <pre><code>steps=[
      {from:1, to:8},
      {from:1, to:2},
      {from:2, to:7},
      {from:7, to:9},
      {from:8, to:9}
  ];
  </code></pre>
  
  <p>this array is describe where does it has connection between two point. For example from 1 to 7 there is a way 1->2->7.</p>
  
  <p>In JavaScript how can I generate the for example the shortest way from 1 to 9?</p>
  
  <p><strong>Updated</strong></p>
  
  <pre><code>function calc_route(start, end, data)
      {           
          console.log(start+", "+end);
          console.log(data);              
          for(var i=0; i&lt;data.length; i++)
          {
  
              if(data[i].topoint == end &amp;&amp; data[i].frompoint == start)
              {
                  console.log("Return");                  
                  console.log(data[i]);
                  return data[i];
              }
              else
              {
                  if(data[i].frompoint == start)
                  {                       
                      calcfor =   data.splice(i, 1);                                      
                      calc_route(calcfor[0].topoint, end, data);
                  }
              }
          }
      }
  </code></pre>
  
  <p>This is what I done until now, my question is how can I save the path?</p>