Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
106
rated 0 times [  107] [ 1]  / answers: 1 / hits: 19100  / 15 Years ago, mon, october 19, 2009, 12:00:00

It doesn't really have to add newlines, just something readable.



Anything better than this?



str = line 1 +
line 2 +
line 3;

More From » string

 Answers
656

Almost identical to NickFitz's answer:



var str = [
,line 1
,line 2
,line 3
].join();
// str will contain line1line2line3


The difference, the code is slightly more maintainable because the lines can be re-ordered without regard to where the commas are. No syntax errors.


[#98488] Wednesday, October 14, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rickjordond

Total Points: 100
Total Questions: 105
Total Answers: 90

Location: Sweden
Member since Mon, May 8, 2023
1 Year ago
rickjordond questions
;