Line breaks while building a string in a for loop

I have a piece of code that looks like this

for (var k=0; k<myArray.length; k++)
		minuslen = myArray.length-1;
		myString += myArray[k];
		if (k<minuslen) {
		myString += " : "+myArray[k+1];
		myString += "\
myArray = myString.split(" : ");

The output will contain a literal
instead of a line break which is not really the desired output. What would be a way to insert the line breaks to get the desired output?

A literal
in JavaScript is written "\
" - the
that you have is a linebreak character and not a literal

Thank you your response felgall.
Yes, I realize the
is a linebreak character and that is the desired character. What I’m getting at and what I don’t understand is why it doesn’t create a linebreak in the output of the final string and instead adds a literal
is it because for the linebreak character to be interpreted I have to call a print/write-to-screen function?

Yes. In JavaScript a linebreak displays as \

  • to get it to actually display as a linebreak you need to view it from outside JavaScript - eg. by writing it into a web page and then viewing the updated source of the page via the browser debugging tools.