title: Convert array to string in AngularJS
body: <p>Im trying to convert an array of Strings, to a single string. I made a quick plunker of what I need in basic terms:</p>
  
  <p><a href="https://plnkr.co/edit/t2KeZJ8yOtDo2KxDQuzD?p=preview" rel="nofollow noreferrer">https://plnkr.co/edit/t2KeZJ8yOtDo2KxDQuzD?p=preview</a></p>
  
  <p>In the app Im working on I need to use two different controllers and I created a factory for the controllers to share data, so I set the example up like that. </p>
  
  <p>Here is the function I am trying to use to loop the array and add to a scope variable, with CherryPick being the array:</p>
  
  <pre><code>cherryCtrl.CherryPick = CherryPick.list;
  cherryCtrl.string = cherryCtrl.output;
  
  
  cherryCtrl.runString = function createString(array) {
  
      angular.forEach(cherryCtrl.CherryPick, function (object) {
          angular.forEach(object, function (value, key) {
              cherryCtrl.output += value + '  ';
  
              console.log(cherryCtrl.output);
          });
      });
      return cherryCtrl.output;
  
  }
  </code></pre>
  
  <p>the console for output gives:</p>
  
  <pre><code>undefinedHello World  
  undefinedHello World  object:5  
  undefinedHello World  object:5  Goodbye World  
  undefinedHello World  object:5  Goodbye World  object:8 
  </code></pre>
  
  <p>Which is confusing.</p>
  
  <p>I took the idea for the loop from here:</p>
  
  <p><a href="https://stackoverflow.com/questions/28435540/array-to-string-angular">Array to string angular</a></p>
  
  <p>Any pointer would be mucho appreciated</p>