DEV Community

Discussion on: 1 line of code: How to convert \newlines to <breaks />

Collapse
 
snigo profile image
Igor Snitkin

Coffee is good! But provided code is syntactically incorrect and I you don't have to know JS to see that, you may just count the number of opening and closing brackets. HTML elements don't actually use self-closing tags - you probably confused it with XML or React. And finally, you should never mix HTML and text content, it's really bad idea. Instead you probably should separate text into array of lines and append them one by one, additionally appending <br> in between.

Collapse
 
martinkr profile image
Martin Krause

Hi Igor,

Thank you for pointing me to the syntactical misstake introduced by the last update.
I fixed the number of brackets.

Cheers!