Showing new lines <br> in the browser when having \n in the database
<p>In mongo I have a document with a field like <code>reviewText: 'this is line 1\nthis is line 2',</code> . I got that from a <code>textarea</code> so the <code>\n</code> is there because the user hit enter. I want to print the text on the screen in a div with a line break (preferably only one line break if he hits many enters) I don't know how to do that I dont get on the screen any <code>\n</code>s</p>

<p>I do <code>&lt;div class = "displayReview"&gt;&lt;%= e.reviewText %&gt;&lt;/div&gt;</code> in EJS that just prints it all on oneline. It gets me <code>&lt;div class="displayReview"&gt;this is line 1 this is line 2&lt;/div&gt;</code> in the browser.</p>

<p>I have someplace in my routes that updates the docs like:</p>

<pre><code>    .then(function(returnedReviews){
        console.log(" returnedReview ",returnedReviews);
        returnedReviews.forEach(function(e){
            e.momented = moment(e.createdAt.getTime()).fromNow()
            // e.reviewText = e.reviewText.replace(/\r?\n/g, '&lt;br /&gt;')
        })
</code></pre>

<p>I tried to do what I have in the comments. but that obviously just put <code>&lt;br /&gt;</code> (the text) in the string and not HTML. I was hoping there was an easy way to do this.</p>

<p>I want to see line breaks when it gets printed to the screen where the user hits enter in the <code>textarea</code> before he sent the form. If the user hits the enter button multiple times in a row there should be only one line break.</p>