Skip to content

Instantly share code, notes, and snippets.

@adamjohnson
Created November 30, 2020 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamjohnson/11a399256ac783e9aa254b47c3a7fdad to your computer and use it in GitHub Desktop.
Save adamjohnson/11a399256ac783e9aa254b47c3a7fdad to your computer and use it in GitHub Desktop.
Using the newline character with the .join() method in JavaScript to combine a string.
let myString = [
'<div class="container">',
'<h2>This is inserted via JS:</h2>',
'<p>',
'The .join() method can accept newline as an argument.',
'Much better than +!',
'</p>',
'</div>'
].join('\n'); // <-- 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment