JavaScript Loops and JSON
<p>I have the following loop below. Data is passed as JSON format. I want to use this for visualisation of a graph. However, I am unable to understand the logic. Can someone elaborate this logic for me please?    </p>

<pre><code>for (var x = 0; x &lt; id_inter['inters'].length; x++) {
  var src,
    tgt;
  if (id_inter['inters'][x]['ID'] == data.initial[0].ID) {
    src = id_inter['inters'][x]['ID'];
    tgt = id_inter['inters'][x]['ID2'];
  } else {
    src = id_inter['inters'][x]['ID2'];
    tgt = id_inter['inters'][x]['ID'];
  }
  var_edges.push({
    data: {
      src: src,
      src: tgt,
      expt_type: id_inter['inters'][x]['expt'],
      name: id_inter['inters'][x]['name'],
      date: id_inter['inters'][x]['date']
    }
  });
}
</code></pre>