Add strings in an array - Javascript
<p>I have an array of text:</p>

<pre><code>var text=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s");
</code></pre>

<p>I would like to add the elements in the array according to a set number and then store these in a new array. For example, if I pick 3, then the resulting strings in the new array (terms) would be: "a b c","d e f", "g h i" etc</p>

<p>I looked at Join and I can't get this to work - it seems to only be able to add the entire array together. I'm guessing I need to use a nested loop, but I can't seem to get this to work. Here's my attempt:</p>

<pre><code>//Outer loop
for (i=0; i &lt; text.length; i++) {
    //Inner loop
    for (j=i; j &lt; i+$numberWords; j++) {
    newWord=text[j];
    newPhrase=newPhrase+" "+newWord;
    }    
terms.push(newPhrase);
i=i+$numberWords;
}
</code></pre>

<p>Thanks in advance.</p>
