Replace multiline with single line in a string+Javascript
<p>I am trying to replace all multiplines with single line in a string in javascript but none is working . Below is my code :</p>

<pre class="lang-js prettyprint-override"><code>var str=inputList.replace(/\n/gm,"\n");
</code></pre>

<p>input e.g. </p>

<pre><code>abc,def &lt;3 newlines&gt;


xyz &lt;1 newline&gt;
opp
</code></pre>

<p>Expected output: </p>

<pre><code>abc,def &lt;1 newline&gt;
xyz
opp
</code></pre>

<p>Actual output: </p>

<pre><code>abc,def&lt;3 newlines&gt;


xyz&lt;1 newline&gt;
opp
</code></pre>

<p>Any help is appreciated.</p>