How to account for spaces in the line?

Hi guys. Faced with such a task.
I have some mesing. To me it is necessary to portray the text in a div let's say, as it is specified.
If simply inserted, the gaps are eliminated and he pouchitsa as one.

How to fix it?

Code - https://jsfiddle.net/upb0tdg3/
June 5th 19 at 21:17
2 answers
June 5th 19 at 21:19
Solution
js is not needed, it is enough to set the css property white-space
#msg {
 white-space: pre-wrap;
}
https://jsfiddle.net/upb0tdg3/1/
And if without css? - Kolby59 commented on June 5th 19 at 21:22
you have a browser which is able js but not css able, or what kind of strange situation?
If no css, then describe in more detail what you want to get the output. - Austen.Thompson53 commented on June 5th 19 at 21:25
Just wondering, is it possible without css - Kolby59 commented on June 5th 19 at 21:28
can. - Austen.Thompson53 commented on June 5th 19 at 21:31
June 5th 19 at 21:21
container.innerHTML=message.replace(/(?:\r\n|\r|\n)/g, '

');

Find more questions by tags JavaScript