Note that there are some explanatory texts on larger screens.

plurals
  1. POcharacter that represents new line across all platforms in JavaScript
    text
    copied!<p><strong>specs</strong></p> <p>I am working on Linux Mint 14. I started on JavaScript recently and I tried to do some output formatting(printing random numbers, one per line) and as usual used <code>\n</code>. But this does not seem to work.</p> <p>On both the chromium web browser and mozilla firefox, only a space shows up.</p> <p><strong>code</strong></p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt; GENERATE RANDOM NUMBERS AND PRINT THEM &lt;/TITLE&gt; &lt;BODY&gt; &lt;div id='container'&gt; &lt;button onclick='startPrinting()'&gt;Generate random numbers &lt;/button&gt; &lt;/div&gt; &lt;/BODY&gt; &lt;/HTML&gt; &lt;/HEAD&gt; &lt;script&gt; function startPrinting() { var b = document.getElementById('container'); //b.innerHTML += Math.floor(Math.random() * 1000); b.innerHTML += '&lt;br&gt;The following are some random numbers.&lt;br&gt;'; for(var i =1;i&lt;10;i++) { b.innerHTML += '\n'; b.innerHTML += i + '.' + Math.floor(Math.random() * 1000); } } &lt;/script&gt; </code></pre> <p>I tried <code>&lt;br&gt;</code> and this worked well. But now I have many files where I have <code>\n</code>.</p> <p>So is there a way that I can tell the script to replace all occurences of <code>\n</code> with <code>&lt;br&gt;</code>?</p> <p>If possible please give an answer that will ensure that i have to add only a few lines of code to my existing files.</p> <p>(I am looking for something like <code>#define</code> in C++)</p> <p><strong>please</strong> help me resolve this issue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload