 <p>Try this (inside your for loop): </p> <p><strong>Updated:</strong> </p> <pre><code>var joiners; for ... { joiners += pings[i].joining_profiles[q].name + " "; var newText = RTRIM(joiners).split(" ").join(","); } </code></pre>