title: Callback function terminates outerloop
body: <pre><code>var items = ['1', '2', 'callback', '4'];
  
  var testCallback = function (item, items) {
      var outputArray = [];
          if (item == 'callback') {
              for (i = 0; i &lt; items.length; i++) {
              outputArray.push(testCallback('5', items));
              console.log(outputArray);
              };
          } else {
              outputArray.push(item);
          };
  
      return outputArray.join(',');
  };
  
  var testFunction = function (items) {
      var output = '';
      for (i = 0; i &lt; items.length; i++) {
          console.log(i);
            output += testCallback(items[i], items);           
      };
  
      console.log(output)   
  };
  
  testFunction(items);
  </code></pre>
  
  <p>Here's example <a href="http://jsfiddle.net/9o57o9k1/" rel="nofollow">fiddle</a>.</p>
  
  <p>I would expect output to be 125,5,5,54 (5,5,5,5 replaces 'callback'). But instead for statement (in testFunction()) terminates after 'callback' and does not proceed to last item in items[] and the output is 125,5,5,5.</p>
  
  <p>Would appreciate any help. Thanks</p>