You can split the string into several words and combine them together by adding "\ n" every fifth word:
function insertLines (a) { var a_split = a.split(" "); var res = ""; for(var i = 0; i < a_split.length; i++) { res += a_split[i] + " "; if ((i+1) % 5 === 0) res += "\n"; } return res; }
Please note that the "\ n" in the html code (for example, in the tag "div" or "p") will not be displayed to the website visitor. In this case, you will need to use "
"
Preli source share