Created
November 30, 2020 21:41
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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