Newlines not appearing where I want them in generated javascript
<p>I am sticking values into a script, and I am using the function below to 'implode' the array</p>

<pre><code>function implode() { var str='';
    for(item in globvars)
       str +='\n'+globvars[item]+';';
    return str+'\n';
}
</code></pre>

<p>Sample usage:</p>

<pre><code>globvars = ['Tom', 'Dick', 'Harry'];
output = '&lt;script type = "text/javascript"&gt;\n'+implode(globvars)+'&lt;/script\&gt;';
</code></pre>

<p>Expected output <strong>should be</strong>:</p>

<pre><code>    &lt;script type = "text/javascript"&gt;
    Tom
    Dick
    Harry
    &lt;/script&gt;

    Instead, I am getting something like this:

    &lt;script type = "text/javascript"&gt;
    Tom Dick Harry &lt;/script&gt;
</code></pre>

<p>what the ... ?</p>
