Thursday 16 March 2017

Extremely easy javaScript code did not work

I used nodeJs to do some simple data processing. Links are array with objects with a source and a target.

For example:

Links=[{source: 'a', target: 'b'},{source: 'b', target: 'c'}]

Now i want to add 4 link to links but it did not work

for(var i=0;i<Links.length;i++){
    for(var j=0;j<2;j++){
      Links.push({
        source: 'yo',
        target: 'yo'
      });
    }
  }

The entire program stuck here (goes for infinite loop).



via SHE

No comments:

Post a Comment